2017-05-03 2 views
0

Ich habe ein Popup in ionischen und haben ein Textfeld und eine Schaltfläche drin. Ich möchte die Eingabetaste drücken, um zu arbeiten und das Popup zu schließen. Ich frage mich, wie Sie diese Aktion in diesem Popup ausführen können.Drücken Enter zum Einreichen in Ionic Popup mit AngularJs

var myPopup = $ionicPopup.show({ 
      template: '<input type = "text" ng-model = "data.model"><br> ' 
      , title: 'Name' 
      , scope: $scope 
      , buttons: [ 
       { 
        text: 'Cancel' 
       }, { 
        text: '<b>Search</b>' 
        , type: 'button-positive' 
        , onTap: function (e) { 
         $ionicLoading.show(); 
         $http.get(HTTPService.getHttpText() + 'Persons/' + $scope.data.model).then(function (resp) { 
          console.log('Success', resp); 
          $ionicLoading.hide(); 
         }, function (err) { 
          $ionicLoading.hide(); 
          console.error('ERR', err); 
          // err.status will contain the status code 
         }) 
        } 
        } 
       ] 
     }); 
+0

Mögliches Duplikat von [Formular beim Drücken der Eingabetaste mit AngularJS senden] (http://StackOverflow.com/questions/15417125/submit-form-on-pressing-enter-with-angularjs) – Pengyy

Antwort

0

Ich würde vorschlagen, dass Sie eine <form> verwenden und Ihre Taste, um type="submit":

<form ng-submit="submitPopup()"> 
    <button type="submit">Close</button> 
</form> 

In der submitPopup Funktion, tun, was Sie wollen, und schließen Sie die modal:

$scope.submitPopup = function() { 
    $http.get(...); 
    myPopup.close(); 
} 
+0

Wo es im Popup hinzugefügt werden kann ? Weil ich Knopf nicht wie normale Weise definiere. – birdcage

0

Wahrscheinlich haben Sie das Button Event gefiltert.

if (e.name = "") ->

ist $ http.get zu arbeiten?

Verwandte Themen