简体   繁体   English

使用Ionic框架将事件添加到设备日历

[英]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? 我正在使用Ionic框架和AngularJS创建一个跨平台的移动应用程序在这个应用程序中,我需要获取一个日期字符串并将其添加到设备的本机日历中,有没有办法只使用Ionic和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 ! 谢谢 !

Check out the Angular wrapper for Cordova calendar: http://ngcordova.com/docs/plugins/calendar/ 查看Cordova日历的Angular包装器: 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: 将ngCordova添加到app.js并安装日历插件后,可以将$ cordovaCalendar注入控制器,然后调用它:

  $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');
    });
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM