2016-06-08 24 views
0

我想在離子中顯示彈出窗口,當用戶沒有輸入某些內容時不允許用戶退出。現在,我使用這個位置:onTap和popUp在離子中的'this'的作用域是'undefined'

public showOwnIdentifierPrompt() { 
     // Prompt popup code 
     var promptPopup = this.$ionicPopup.prompt({ 
     title: this.floor_name, 
     template: `<input ng-model="$ctrl.customFloorName"></input>`, 
     scope: this.$scope, 
     buttons: [ 
      { 
      text: this.cancel, 
      type: 'button-clear button-balanced', 
      onTap: function(e) { 
       // Cancel creation 
       return false; 
      } 
      }, 
      { 
      text: this.save, 
      type: 'button-clear button-balanced', 
      onTap:() => { 
       // Create new floor 
       return true; 
      } 
      } 
     ] 
     }); 

     promptPopup.then((res) => { 
     if (res) { 
      this.addNewFloor(this.customFloorName); 
     } 
     }) 
} 

在保存onTap()事件處理程序,我想從我的課訪問this.customFloorName,決定用戶是否輸入的輸入。但它總是未定義的。我能做什麼?

回答

1

您可以保存得值與下面的代碼:

var value = this.scope.$ctrl.customFloorName; 
相關問題