0
我有我的組件的提示警告類似如下:Ionic2綁定值提示警報
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);
}
對於「區域」我想填充它的價值,是一個類級別的變量稱爲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)
...
}
}
這不會填充提示警報中的值,只能分配字符串。我如何實現這一目標?
這是'this.area'屬性的*類型*? – sebaferreras
它是任何,但我給它分配一個數值 – Nitish
當你設置'name','placeholder'和'value'屬性時,你是否嘗試過添加'type:'number''? – sebaferreras