2014-09-05 61 views

回答

1

是其可能的检查例如here

angular.module('submitExample', []) 
    .controller('ExampleController', ['$scope', function($scope) { 
     $scope.list = []; 
     $scope.text = 'hello'; 
     $scope.a = function(){ 
     alert(0); 
     } 
     $scope.submit = function() { 
     if ($scope.text) { 
      $scope.list.push(this.text); 
      $scope.text = ''; 
     } 
     }; 
    }]); 

而且标记:

<form ng-submit="submit(); a()" ng-controller="ExampleController"> 
    Enter text and hit enter: 
    <input type="text" ng-model="text" name="text" /> 
    <input type="submit" id="submit" value="Submit" /> 
    <pre>list={{list}}</pre> 
</form> 
+0

你知道哪种方法是先从submit()或a()..开火吗? – 2016-11-15 08:39:09

0

是的,你可以不喜欢它:

ng-submit="methodA(); methodB();" 

see plunker

相关问题