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

Refresh events on calander #177

Open
Raagu1993 opened this issue Dec 14, 2018 · 3 comments
Open

Refresh events on calander #177

Raagu1993 opened this issue Dec 14, 2018 · 3 comments

Comments

@Raagu1993
Copy link

When I redirect to a calendar page I am not seeing any events on week view from the back end. when I click on month view and come back to week view events are loading. Could you please suggest me how to get events in the initial view.

I am new for this technology. so, please suggest me with clear explanation.

@twinssbc
Copy link
Owner

@Raagu1993 Could you provide your code to demonstrate how do you load the events? The calendar watches the eventSource variable, once you fetch the events, you assign them to the eventSource in your callback method. The calendar should be able to display them.

@Raagu1993
Copy link
Author

I am geting events by calling getEvents function and pushing to "$scope.calendar.eventSource". Kindly find the below code for your reference.

//Get All events Start
$scope.getEvents = function(){
miappServices.getEvents($scope.accountId).then(function(response) {
$scope.response = response;
for(var i=0; i<=$scope.response.length; i++){
$scope.response[i].startTime = new Date(response[i].startTime);
$scope.response[i].endTime = new Date(response[i].endTime)
$scope.calendar.eventSource.push(response[i]);
}
}, function(err) {
// $scope.calendar.mode = err.details;
})
}
$scope.getEvents();

//Get All events End

$scope.calendar = {
currentDate: new Date(),
mode: 'week',
eventSource: [
{
host : "Raghavendra",
subject : "Project Discussion",
title: 'Event 1',
startTime: new Date(Date.UTC(2018, 11, 7, 5, 00, 00)),
endTime: new Date(Date.UTC(2018, 11, 7, 7, 00, 00)),
allDay: false
}
]
};

@twinssbc
Copy link
Owner

twinssbc commented Dec 15, 2018

@Raagu1993 Directly pushing element to eventSource doesn't take effect.
I explained in the README.

Note In the current version, the calendar controller only watches for the eventSource reference as it's the least expensive. That means only you manually reassign the eventSource value, the controller get notified, and this is usually fit to the scenario when the range is changed, you load a new data set from the backend. In case you want to manually insert/remove/update the element in the eventSource array, you can call broadcast the 'eventSourceChanged' event to notify the controller manually.

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