无法创建日历事件离子日历

时间:2019-03-22 15:06:41

标签: typescript ionic-framework calendar

我一直在尝试使用离子日历创建日历事件,但是我收到的只是“ object(...)不是函数”。香港专业教育学院导入离子日历和插件,我尝试过的一切都失败了。这是我的代码。

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, AlertController } from 'ionic-angular';
import { Calendar } from '@ionic-native/calendar/ngx';


@IonicPage()
@Component({
  selector: 'page-add-event',
  templateUrl: 'add-event.html',
})
export class AddEventPage {

	  event = { title: "", location: "", message: "", startDate: "", endDate: "" };


  constructor(public alertCtrl: AlertController,
  public navCtrl: NavController,
  public navParams: NavParams,
  private calendar: Calendar) {
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad AddEventPage');
  }

  save() {
  	this.event.title = "";
  	this.event.location = "";
  	this.event.message = "";
  	this.event.startDate = "";
  	this.event.endDate = "";
  	
  this.calendar.createEvent(this.event.title, this.event.location, 
  	this.event.message, new Date(this.event.startDate), new Date(this.event.endDate)).then(
    (msg) => {
      let alert = this.alertCtrl.create({
        title: 'Success!',
        subTitle: 'Event saved successfully',
        buttons: ['OK']
      });
      alert.present();
      this.navCtrl.pop();
    },
    (err) => {
      let alert = this.alertCtrl.create({
        title: 'Failed!',
        subTitle: err,
        buttons: ['OK']
      });
      alert.present();
    }
  );
}

0 个答案:

没有答案