2
我正在構建一個Ionic2應用程序。我有一個像下面的一個警告:帶下拉的Ionic2警報?
constructor(private platform: Platform, public nav : NavController,
public exhibitionSurveyObjectService : ExhibitionSurveyObjectService) {
this.initializeMap();
this.nav=nav;
this.testArray=[];
this.area=null;
}
addSurveyObject(){
let prompt = Alert.create({
title: 'Subscribe to our service',
message: "All the fields are necessary",
inputs: [
{
name: 'name',
placeholder: 'Name'
},
....
{
name: 'cycle',
placeholder: 'Cycle: once/weekly/monthly'
},
{
name: 'object_type',
placeholder: 'Farm/Solarpanel/plain'
},
],
buttons: [
....
{
text: 'Save',
handler: data => {
this.createExhibitionSuveyObject(data);
}
}
]
});
this.nav.present(prompt);
}
createExhibitionSuveyObject(data: any){
var cycle = data.cycle;
cycle = cycle.toUpperCase()
console.log(cycle)
var type = data.object_type;
type = type.toUpperCase()
console.log(type)
this.exhibitionSurveyObjectService.addObject(
data.name, data.farmer_email,
data.farmer_name, data.size, data.path, cycle, type).subscribe(
response => {
this.exhibitionSurveyObjects = response;
this.sayThanks();
},
error => {
this.errorMessage = <any>error;
console.log("error")
}
);
}
sayThanks(){
let alert = Alert.create({
title: 'Thank you!',
subTitle: 'We have received your data, we will get back to you soon!',
buttons: [{
text: 'Ok',
handler:() => {
this.nav.push(HomePage)
}
}]
});
this.nav.present(alert);
}
我想最後兩個字段是下拉菜單。我怎樣才能做到這一點?
UPDATE:更新了代碼片段,並增加了一些代碼。如何更新以使用Modal而不是alert?
所以我完全刪除警報,而是使用模態?我正在用更多的代碼更新代碼片段。 – Nitish
@Nitish是的,Alertboxes是非常快速的提示..即使你需要2個文本域我肯定會去一個更好的用戶界面模式! – EralpB
謝謝!我這樣實現它! – Nitish