属性 'inputs' 不存在于类型 '{ title: string; buttons:in离子3?
Property 'inputs' does not exist on type '{ title: string; buttons:in ionic3?
见鬼去吧,
我已经调用我动态创建复选框并将 KeyId 推入数组但是我遇到了上述错误我已经声明了类型但我不明白有这个错误?
options.inputs = [];
//Here we will generate dynamically check-box
for(let i=0; i< data.subCategoriesDtos.length; i++) {
this.subCategoryObject = data.subCategoriesDtos[i];
options.inputs.push({
value: this.subCategoryObject.keyId,
label: this.subCategoryObject.subCategoryName,
type: 'checkbox',
checked: this.showSelectedSubcategory(this.selectedSubcategoryArray[i])
});
}
// Create the alert with the options
let alert = this.alertCtrl.create(options);
alert.present();
正确的方法是使用 Alert
实例中的 addInput(...)
方法来添加输入:
addInput(input: AlertInputOptions): Alert;
export interface AlertInputOptions {
type?: string;
name?: string | number;
placeholder?: string;
value?: string;
label?: string;
checked?: boolean;
disabled?: boolean;
id?: string;
handler?: Function;
min?: string | number;
max?: string | number;
}
所以使用你的代码看起来像这样:
import { AlertController, Alert, ... } from 'ionic-angular';
// ...
public showAlert(): Promise<any> {
// Create the alert with no options
let alert: Alert = this.alertCtrl.create({});
// Here we will generate dynamically check-box
for(let i=0; i< data.subCategoriesDtos.length; i++) {
this.subCategoryObject = data.subCategoriesDtos[i];
alert.addInput({
value: this.subCategoryObject.keyId,
label: this.subCategoryObject.subCategoryName,
type: 'checkbox',
checked: this.showSelectedSubcategory(this.selectedSubcategoryArray[i])
});
}
return alert.present();
}
见鬼去吧, 我已经调用我动态创建复选框并将 KeyId 推入数组但是我遇到了上述错误我已经声明了类型但我不明白有这个错误?
options.inputs = [];
//Here we will generate dynamically check-box
for(let i=0; i< data.subCategoriesDtos.length; i++) {
this.subCategoryObject = data.subCategoriesDtos[i];
options.inputs.push({
value: this.subCategoryObject.keyId,
label: this.subCategoryObject.subCategoryName,
type: 'checkbox',
checked: this.showSelectedSubcategory(this.selectedSubcategoryArray[i])
});
}
// Create the alert with the options
let alert = this.alertCtrl.create(options);
alert.present();
正确的方法是使用 Alert
实例中的 addInput(...)
方法来添加输入:
addInput(input: AlertInputOptions): Alert; export interface AlertInputOptions { type?: string; name?: string | number; placeholder?: string; value?: string; label?: string; checked?: boolean; disabled?: boolean; id?: string; handler?: Function; min?: string | number; max?: string | number; }
所以使用你的代码看起来像这样:
import { AlertController, Alert, ... } from 'ionic-angular';
// ...
public showAlert(): Promise<any> {
// Create the alert with no options
let alert: Alert = this.alertCtrl.create({});
// Here we will generate dynamically check-box
for(let i=0; i< data.subCategoriesDtos.length; i++) {
this.subCategoryObject = data.subCategoriesDtos[i];
alert.addInput({
value: this.subCategoryObject.keyId,
label: this.subCategoryObject.subCategoryName,
type: 'checkbox',
checked: this.showSelectedSubcategory(this.selectedSubcategoryArray[i])
});
}
return alert.present();
}