Open vivek9091 opened 7 years ago
@vivek9091 Your createEvents method is an async method, you need to manipulate the eventSource variable in your callback. In your current logic, at the time executing $scope.eventSource = createEvents(), nothing is passed to eventSource.
Hello, I have updated query-mode to remote in calendar-tpls.js file . I am reading data from backend.
I have updated 'reloadSource' function. calendar ng-model="currentDate" calendar-mode="mode" event-source="eventSource" range-changed="reloadSource(startTime, endTime)" event-selected="onEventSelected(event)" time-selected="onTimeSelected(selectedTime, events)"
$scope.reloadSource = function (startTime, endTime){ //Events.query({startTime: startTime, endTime: endTime}, function(events){ //$scope.eventSource=events; $scope.eventSource = createEvents(); //}); };
Here is my createEvents function. function createEvents() { var events = [] ;
$q.all([ EventsService.getAll().$promise ]).then(function (data) { var users = data[0]; users.forEach(function (user) { var date=new Date(); var eventType = user.isFullDay; var endTime= null; if (user.endAt != null || user.endAt != "") endTime=new Date(user.endAt); //console.log(user); if (eventType === 0) { events.push({ title:user.title, startTime: new Date(user.startAt), endTime: endTime, allDay: true }); } else { events.push({ title:user.title, startTime: new Date(user.startAt), endTime: endTime, allDay: false }); //console.log(" startTime: "+new Date(user.startAt)+" endTime: "+ new Date(user.endAt)); } $scope.loadEvents = function () { $scope.eventSource = createEvents(); }; }); }); return events; // $scope.$broadcast('eventSourceChanged',events); } When i am updating query-mode to 'local', same function createEvents is feeding data into eventSource and it is displaying events. $scope.loadEvents = function () { $scope.eventSource = createEvents(); }; can you please suggest, what i am missing.