Reputation: 11
I have to use the methode getDate as mentionned in this doc: http://fullcalendar.io/docs/current_date/getDate/ But i use angular
But i can't access the element "calendar" who is undefined.
My call to the calendar :
<div class="calendar col-sm-8" data-ng-model="eventSources" data-ui-calendar="uiConfig.calendar" data-calendar="myCalendar" ></div>
My controller:
$scope.uiConfig = {
calendar:{
lang: 'fr',
weekends: true,
eventLimite: 4,
dayClick:function(date, jsEvent, view){
//My dayClick function
eventClick: function(calEvent, jsEvent, view){
//My EventClick function
}
}
};
$scope.date=$scope.myCalendar.fullCalendar.getDate();
I also tried :
$scope.uiConfig.calendar.fullCalendar.getDate()
But fullCalendar is not defined.
Also
$scope.uiConfig.calendar.getDate();
This time getDate isn't a function
Upvotes: 1
Views: 1569
Reputation: 3367
Change
$scope.date=$scope.myCalendar.fullCalendar.getDate();
To:
$scope.date=$scope.myCalendar.fullCalendar('getDate');
In addition, assuming you are using angular-ui calendar, your calendar will be part of the array of calendars you have in your controller, which can manage more than one calendar.
From angular-ui documentation:
It is possible to access a specific calendar object by declaring a name for it on the uiCalendar directive. In this next line we are naming the calendar 'myCalendar'. This will be attached to the uiCalendarConfig constant object, that can be accessed via DI.
<div ui-calendar="calendarOptions" ng-model="eventSources" calendar="myCalendar">
Now the calendar object is available in uiCalendarConfig.calendars:
uiCalendarConfig.calendars.myCalendar
This allows you to declare any number of calendar objects with distinct names.
Check your references or feel free to fork my plnkr with angularUi
Upvotes: 1