Reputation: 252
I have a question concerning the Angular-UI Calendar directive for Fullcalendar. I am new to angular and I am trying to filter the events from the single eventsource my app uses. What I would like to accomplish is perform a front-end filter on the full result set from my resource and update the calendar accordingly.
I am fetching my events like so:
$scope.eventSources = [$scope.events];
$scope.events = function (start, end, callback) {
var events = VergaderingCalendarEvents.list({
start: start.getTime() / 1000,
end: end.getTime() / 1000
});
// Belofte maakt schuld
events.$promise.then(function (val) {
$scope.events = events;
callback($scope.events);
}
);
};
this returns a JSON array with objects in this format:
[{"id":1,"title":"CBS","allDay":false,"status":"OPEN","start":"2013-11-27T14:00Z","end":"2013-11-27T18:00Z"}]
And now I would like to filter this result on status from the controller using a select value. I have found some sample code which swaps out elements from the $scope.eventSources array but thats not exactly what I would like to accomplish. I would just like to filter this result in an Angular correct way. If necissary I can create a plunker for this later today.
Thanks for your time.
Bart
Upvotes: 3
Views: 1918
Reputation: 1033
Easiest and most efficient would be to send a request with the correct filter in each time you change the status filter, and get the correct list back from the api, but that does not solve the client side question you asked.
To perform the filter via the client, you would need to filter the events inside the promise function right before you set the events to the $scope.
$scope.events = $filter('statusFilter')(events,status)
Upvotes: 2