mattlewis92 / angular-bootstrap-calendar

A port of the bootstrap calendar widget to AngularJS (no jQuery required!)
https://mattlewis92.github.io/angular-bootstrap-calendar/
MIT License
798 stars 369 forks source link

event from JSON - API #579

Closed yasserht closed 7 years ago

yasserht commented 7 years ago

Hello, I wanna ask how can I get external draggable events from a JSON file or API, also events on the calendar. here's the starter plunker : http://plnkr.co/edit/6ptfCC1k1izm76Hw8Aox?p=preview

mattlewis92 commented 7 years ago

You would just load them with $http like any other request for data and then map them to a format the calendar understands:

// GET /events returns [{title: 'event-title', start: '2017-04-01'}]
$http.get('/events').then(function(result) {
  vm.externalEvents = result.data.map(function(apiEvent) {
    return {
        title: apiEvent.title,
        type: 'warning',
        color: calendarConfig.colorTypes.warning,
        startsAt: new Date(apiEvent.start),
        draggable: true
      };
  });
});

Hope that helps!

yasserht commented 7 years ago

Hello @mattlewis92 I have two questions does this // GET /events returns [{title: 'event-title', start: '2017-04-01'}] give me events for that exact date ? and what if i want events for a range of dates ? thank you