Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding events to device calendar using Ionic framework

I'm creating a cross platform mobile app using Ionic framework and AngularJS In this app I need to get a date string and add it to the device's native calendar, is there a way to do so using only Ionic and AngularJS? and if there's no way to do so, can you tell me if there's a way doing so without them? Thank You !

like image 581
Joseph Khella Avatar asked Mar 18 '23 10:03

Joseph Khella


1 Answers

Check out the Angular wrapper for Cordova calendar: http://ngcordova.com/docs/plugins/calendar/

Once you add ngCordova to your app.js and install the calendar plugin, you can inject $cordovaCalendar into your controller, then call it like this:

  $scope.createEvent = function(event){
    // Add to calendar interactively (vs silently):
    $cordovaCalendar.createEventInteractively({
      title: event.summary,
      location: event.location,
      notes: event.description,
      startDate: startsAt,
      endDate: endsAt
      // startDate: new Date(2015, 0, 6, 18, 30, 0, 0, 0),
      // endDate: new Date(2015, 1, 6, 12, 0, 0, 0, 0)
    }).then(function (result) {
      // success
    }, function (err) {
      // alert('Oops, something went wrong');
    });
  }
like image 163
Ira Herman Avatar answered Mar 22 '23 22:03

Ira Herman