Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

View is not updating when query-mode is set to remote #70

Open
vivek9091 opened this issue Jun 7, 2017 · 1 comment
Open

View is not updating when query-mode is set to remote #70

vivek9091 opened this issue Jun 7, 2017 · 1 comment

Comments

@vivek9091
Copy link

vivek9091 commented Jun 7, 2017

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.

@twinssbc
Copy link
Owner

twinssbc commented Jun 8, 2017

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants