getcode
是我想从用户那里获取的值并将其传递给 getCoupon
函数,然后我想将结果传递给另一个警报,并在消息属性中显示优惠券,而无需获得[object object]
showPrompt(message,offer,getcode) {
this.peopleservice.getCoupun(offer,getcode).subscribe(data=> this.Code=data);
let prompt = this.alertCtrl.create({
title: 'code',
message: message,
inputs: [{
name: 'Code',
placeholder: 'code',
}],
buttons: [{
text: 'Cancel',
handler: data => {
console.log('Cancel clicked');
}
},{
text: 'ok',
handler: data => {
this.Coupun();
}
}
Coupun(){
let prompt =
this.alertCtrl.create({
title: ' code ',
message:"the result for the getCoupun request",
buttons:[{
text: 'Cancel',
handler: data => {
console.log('Cancel');
}
}]
});
prompt.present();
}
实现的步骤
- 安装Cordova动作表插件
-
在控制器中
`import {component}来自'@angular/core'; 从'ionic-angular'导入{navController,navParams}; 导入{ActionSheet,ActionSheetOptions}来自'@ionic-native/action-sheet'; 令ButtonLabelStoshow = ['通过Facebook共享','通过Twitter共享']; @成分({ 选择器:'Page-Action-Demo', TemplateUrl:" Action-sheet-demo.html", }(( 导出类ActionsHeetDemopage {
/**操作表选项*/ 选项:ActionSheetOptions = { 标题:"与世界分享此图像", 字幕:"从各种选项中选择", 纽扣标签:ButtonLabelStoshow, AddCancelButtonWithLabel:"取消", addStrestiveButtonWithlabel:'delete', DestructiveButtonLast:是的 }constructor(private actionSheet: ActionSheet, public navCtrl: NavController, public navParams: NavParams) { } ionViewDidLoad() { console.log('ionViewDidLoad ActionSheetDemoPage'); } openActionSheet() { this.actionSheet.show(this.options).then((buttonClickedIndex: number) => { console.log('Button pressed is' + buttonClickedIndex) }).catch((err) => { console.log(err) }); }
}`
3.in模板
<button ion-button (click)="openActionSheet()">Button</button>