AngularJS Basic ng submit Simple Example
- 2021-07-07 06:27:26
- OfStack
AngularJS ng-submit Directive
AngularJS instance
Execute the function after the form is submitted:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://apps.bdimg.com/libs/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> The following example demonstrates that after a form is submitted, AngularJS Execute the line. </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>
</html>
Definition and usage
The ng-submit directive is used to execute the specified function after the form is submitted.
Grammar
<
form ng-submit="expression"
>
<
/form
>
<
form
>
Element supports this attribute.
Parameter value
值 | 描述 |
---|---|
expression | 表单提交后函数将被调用,或者1个表达式将被执行,表达式返回函数调用。 |
The above is the basic data collation of AngularJS jg-submit instructions, and the follow-up will continue to be supplemented. Friends who need to learn can look at it.