离子2 - 'ActionSheetController'

时间:2017-07-29 06:27:03

标签: ionic-framework ionic2

我正在关注尝试创建动态表单的doc。不确定为什么在Property 'dismiss' does not exist on type 'ActionSheetController'dismiss()上为Cannot find name someAsyncOperation收到错误消息someAsyncOperation()

我错过了什么吗?

import { ActionSheetController } from 'ionic-angular';
import { IonicPage, NavController, NavParams, ModalController, ViewController } from 'ionic-angular';
constructor(
 public viewCtrl: ViewController,
 public navCtrl: NavController, 
 public actionSheetCtrl: ActionSheetController,
 public modalCtrl: ModalController,
 public navParams: NavParams,
) {}

openActSheet(){

    let actionSheet = this.actionSheetCtrl.create({

    title:"Type",
    buttons:[
    {
    text: 'Hour',
    handler: () => {

            let navTransition = this.actionSheetCtrl.dismiss();

            someAsyncOperation().then(() => {
                    console.log("text");
            })


            navTransition.then(() => {

                this.navCtrl.pop();

            }); 
    }
    },
{
 text: 'Day',
 handler: function(){
 console.log("Day Clicked");
 }
},
{
 text: 'Week',
 handler: function(){
 console.log("Week Clicked");
 }
},
{
 text: 'Month',
 handler: function(){
 console.log("Month Clicked");
 }
}
]
 });
 actionSheet.present();
}

1 个答案:

答案 0 :(得分:1)

ActionSheetController 没有dismiss()功能。它可以在actionsheet对象中使用。

尝试:

openActSheet(){

    let actionSheet = this.actionSheetCtrl.create({

    title:"Type",
    buttons:[
    {
    text: 'Hour',
    handler: () => {

            let navTransition = actionSheet.dismiss(); //here
   //....