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

source is undefined #429

Closed LJaschinski closed 8 years ago

LJaschinski commented 8 years ago

hello guys, I'm trying to create a very simple calendar for the beginning. I just have : <div class="calendar" ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>

and in my controller :

var date = new Date();
    var d = date.getDate();
    var m = date.getMonth();
    var y = date.getFullYear();

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

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

    $scope.events = [
      {title: 'Event',start: new Date(y, m, 1)},
    ];

but i have the error "Error: source is undefined" and i don't understand why... Maybe a problem with my installation of fullCalendar ?

LJaschinski commented 8 years ago

I found the solution, just switch $scope.eventSources and $scope.events, like this :

    $scope.events = [
      {title: 'Event',start: new Date(y, m, 1)},
    ];

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

It seems that eventSources has to be defined at the end of the controller.