表單提交后執(zhí)行函數(shù):
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="https://cdn.staticfile.org/angular.js/1.4.6/angular.min.js"></script> </head> <body ng-app="myApp" ng-controller="myCtrl"> <form ng-submit="myFunc()"> <input type="text"> <input type="submit"> </form> <p>{{myTxt}}</p> <p>以下示例演示了表單提交后 AngularJS 執(zhí)行行。</p> <script> var app = angular.module("myApp", []); app.controller("myCtrl", function($scope) { $scope.myTxt = "你還沒(méi)有點(diǎn)擊提交!"; $scope.myFunc = function () { $scope.myTxt = "你點(diǎn)擊了提交!"; } }); </script> </body> </html>測(cè)試看看 ?/?
ng-submit 指令用于在表單提交后執(zhí)行指定函數(shù)。
<form ng-submit="expression"></form>
<form> 元素支持該屬性。
值 | 描述 |
---|---|
expression | 表單提交后函數(shù)將被調(diào)用,或者一個(gè)表達(dá)式將被執(zhí)行,表達(dá)式返回函數(shù)調(diào)用。 |