这是我的代码:
public add() {
let alert = Alert.create({
title: "Add Date & Time",
message: "Enter the date and time of your donation.",
inputs: [
{
name: "date",
placeholder: "DD/MM/YYYY"
},
{
name: "time",
placeholder: "HH:MM AM/PM"
}
],
buttons: [
{
text: "Cancel"
},
{
text: "Save",
handler: data => {
this.donationHistoryList.push({
date: data.date,
time: data.time
});
}
}
]
});
this.navCtrl.present(alert);
}
以下是我遇到的错误
财产'创造' “警报”类型中不存在。
和
物业'现在'在' NavController'的类型中不存在。
答案 0 :(得分:0)
使用此代码。
import {AlertController} from 'ionic-angular';
在你的构造函数fn
中constructor(private alertCtrl: AlertController) {
}
public add() {
let alert = alertCtrl.create({
title: "Add Date & Time",
message: "Enter the date and time of your donation.",
inputs: [ { name: "date", placeholder: "DD/MM/YYYY" }, { name: "time", placeholder: "HH:MM AM/PM" } ],
buttons: [ { text: "Cancel" }, { text: "Save", handler: data => { this.donationHistoryList.push({ date: data.date, time: data.time }); } }]
});
alert.present(); }
希望这会对你有所帮助。感谢。
答案 1 :(得分:0)
只需添加(这在alertCtrl变量之前)。
this.alertCtrl.create(...)