AngularJS ng-submitDirective
AngularJS Example
Execute function after form submission:
<body ng-app="myApp" ng-controller="myCtrl">
<form ng-submit="myFunc()">
<input type="text">
<input type="submit">
</form>
<p>{{myTxt}}</p>
<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.myTxt = "You haven't clicked submit yet!";
$scope.myFunc = function () {
$scope.myTxt = "You clicked submit!";
}
});
</script>
</body>
<form ng-submit="myFunc()">
<input type="text">
<input type="submit">
</form>
<p>{{myTxt}}</p>
<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.myTxt = "You haven't clicked submit yet!";
$scope.myFunc = function () {
$scope.myTxt = "You clicked submit!";
}
});
</script>
</body>
Try it »
Definition and Usage
ng-submitThe directive is used to execute a specified function after the form is submitted.
Syntax
<form ng-submit="expression"></form>
The <form> element supports this attribute.
Parameter Value
| Value | Description |
|---|---|
| expression | The function will be called after the form is submitted, or an expression will be executed, and the expression returns a function call. |
Other Extensions
AngularJS Reference Manual