angular-ui / ui-calendar

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

eventSources is undefined #247

Closed patatoid closed 9 years ago

patatoid commented 9 years ago

https://github.com/angular-ui/ui-calendar/blob/master/src/calendar.js#L204

var sources = scope.eventSources, should be var sources = scope.$parent.eventSources,

LilBiggs commented 9 years ago

scope.eventSources is the correct code. You do not want to create a tight coupling to the $parent.eventSources variable. What if the end user decides to store their event sources in a variable named allEventSources. Or if the $parent.$parent holds the eventSources object. What scope.eventSources is doing, is binding to the variable passed to the uiCalendar object via the ng-model attribute defined in the directives scope property.

See this line, scope.eventSources is really this object: https://github.com/angular-ui/ui-calendar/blob/master/src/calendar.js#L200

The following scope.eventSources would bind to the allEventSources variable.

//Controller
scope.allEventSources = [
 eventSource1,
 eventSource2 ];
<!-- html -->
<div ui-calendar="uiConfig.calendar" class="calendar" ng-model="allEventSources"></div>
patatoid commented 9 years ago

got it :) thx