2017-07-29 90 views
0

我正在关注试图创建工作表的doc。不知道为什么在dismiss()Cannot find name someAsyncOperation上获得someAsyncOperation()的错误消息Property 'dismiss' does not exist on type 'ActionSheetController'离子2 - 属性'dismiss'不存在类型'ActionSheetController'

我错过了什么吗?

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(); 
} 
+0

哪里定义someAsyncOperation? –

+0

嗨,我没有定义它。在使用它之前是否需要定义该功能?对不起,第一次使用ActionSheet不熟悉它。 – aaa

+0

这是一个自定义JavaScript函数..你需要定义需要发生什么动作。该文档只是一个示例演示.. –

回答

1

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

尝试:

openActSheet(){ 

    let actionSheet = this.actionSheetCtrl.create({ 

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

      let navTransition = actionSheet.dismiss(); //here 
    //.... 
相关问题