我正在尝试为Ionic项目中的提示创建一个模式,但是使用以下代码却出现标题错误:
import { Component } from '@angular/core';
import { ModalController, NavController, NavParams } from 'ionic-angular';
import { AlertController } from 'ionic-angular';
import { EventModalPage } from '../event-modal/event-modal';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
currentEvent;
events = [];
today = new Date();
constructor (
public navCtrl: NavController,
public alertCtrl: AlertController,
public modalCtrl: ModalController) {
this.navCtrl = navCtrl;
this.alertCtrl = alertCtrl;
this.modalCtrl = modalCtrl;
}
onChange($event) {
console.log($event);
this.currentEvent = $event;
}
async presentEventModal() {
const eventModal = await this.modalCtrl.create({
component: EventModalPage
});
return await this.modalCtrl.present();
}
createEvent(date, title, duration) {
return {
date: date,
title: title,
duration: duration,
}
}
}
我正在遵循我发现的here的官方Ionic文档,但是由于某种原因,我收到错误消息,类型present
上没有属性ModalController
>
我正在使用Ionic 3.20.0-不确定是否真的很重要。
答案 0 :(得分:2)
您要在控制器上调用present()
,您需要像在模态上那样调用它:
return await eventModal.present();