2017-07-29 86 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 
    //.... 
相關問題