2016-06-08 3 views
0

Ich möchte ein PopUp in ionic anzeigen, das es dem Benutzer nicht erlaubt, zu beenden, wenn er keine Eingabe eingegeben hat. Im Moment bin ich mit diesem hier:Scope von 'this' on onTap und on popUp in ionic ist '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); 
     } 
     }) 
} 

Im onTap() Event-Handler speichern, würde ich this.customFloorName aus meiner Klasse zugreifen möchte, zu entscheiden, ob die Benutzereingabe eingegeben. Aber es ist immer undefiniert. Was kann ich tun?

Antwort

1

Sie Wert auf Speicher mit folgendem Code erhalten:

var value = this.scope.$ctrl.customFloorName; 
Verwandte Themen