AngularJS- ng-submit
Direktive
Beispiel
Führen Sie eine Funktion aus, wenn das Formular gesendet wird:
<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 have not yet clicked submit";
$scope.myFunc =
function () {
$scope.myTxt =
"You clicked submit!";
}
});
</script>
</body>
Definition und Verwendung
Die ng-submit
Direktive gibt eine Funktion an, die ausgeführt werden soll, wenn das Formular gesendet wird.
Wenn das Formular kein action
ng-submit
Testament enthält, wird das Absenden des Formulars verhindert.
Syntax
<form ng-submit="expression"></form>
Unterstützt durch das <form>-Element.
Parameterwerte
Value | Description |
---|---|
expression | A function to be called when the form is being submitted, or an expression to be evaluated, which should return a function call. |