我的组件中有一个提示警告,如下所示:
addSurveyObject(){
let prompt = Alert.create({
title: 'Add Survey Object',
message: "All the fields are necessary",
inputs: [
{
name: 'name',
placeholder: 'Name'
},
{
name: 'area',
placeholder: 'Area',
value: this.area
},
],
buttons: [
{
text: 'Cancel',
handler: data => {
console.log('Cancel clicked');
}
},
{
text: 'Save',
handler: data => {
this.createSuveyObject(data);
}
}
]
});
this.nav.present(prompt);
}
对于' area'我想将它的值填充到一个名为this.area
的类级别变量中,该变量的值如下:
calcar(shape) {
const area = google.maps.geometry.spherical.computeArea(shape.getPath());
document.getElementById("area").innerHTML = "Area =" + area.toFixed(2);
this.area = area;
console.log(this.area)
...
}
}
这不会填充提示警报中的值,只能分配字符串。我是怎么做到的?
答案 0 :(得分:2)
评论中的答案奏效了。我刚修改了一下我的代码,如下所示:
export class StartPage {
private area: any;
constructor(){
this.area=null
}
警惕:
{
name: 'size',
placeholder: 'Size',
type: 'number',
value: this.area
},