angular-ui / ui-calendar

A complete AngularJS directive for the Arshaw FullCalendar.
http://angular-ui.github.io/ui-calendar/
MIT License
1.49k stars 728 forks source link

How to retrieve data from $$state object in the controller ? #359

Closed HashtagPurvi closed 8 years ago

HashtagPurvi commented 8 years ago

I have the following code

app.controller("calendarController", ["$scope", "displayCalendar", "dialogs", "$filter","$compile","$timeout", function ($scope, displayCalendar, dialogs, $filter,$compile,$timeout) {

    $scope.$parent.pageTitle = "Displays Reporting Period Start and End Dates";

    $scope.eventsources = [];
    $scope.eventSources = [];

    //Fetch Calendar Data
    $scope.eventsources = displayCalendar.getEvents().then(function (result) {
            var eventsources = result;
            for (var i = 0; i < eventsources.length; i++) {
                eventsources[i].start_date = $filter('date')(eventsources[i].start_date, "yyyy-MM-dd");
                eventsources[i].end_date = $filter('date')(eventsources[i].end_date, "yyyy-MM-dd");

               eventsources[i] =
                    {
                        title: eventsources[i].name,
                           start: eventsources[i].start_date,
                           end: eventsources[i].end_date,
                          allDay: false              
                    };
            }
            return eventsources;
    });
     console.log("After function");
     console.log($scope.eventsources);

     $scope.eventSources = eventsources;
    console.log($scope.eventSources);

    /* Render Tooltip */
    $scope.eventRender = function (testevents, element, view) {
        element.attr({
            'tooltip': testevents.title,
            'tooltip-append-to-body': true
        });
        $compile(element)($scope);
    };

    $scope.uiConfig = {
        calendar: {
            height: 450,
            editable: true,
            header: {
                left:   'title',
                center: '',
                right:  'today prev,next'
            },
            eventRender: $scope.eventRender
        }
    };   

}]);

The $scope.eventSources returns a $$state object. Something like this :

 d
$$state: Object
status: 1
value: Array[3]
0: Object
1: Object
2: Object
length: 3
__proto__: Array[0]__proto__: Object__proto__: Object

I want to use the data contained in value. Any idea how can I do that ?