ng-submit
Direttiva AngularJS
Esempio
Esegui una funzione quando il modulo viene inviato:
<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>
Definizione e utilizzo
La ng-submit
direttiva specifica una funzione da eseguire quando il modulo viene inviato.
Se il modulo non ha un action
ng-submit
, impedirà l'invio del modulo.
Sintassi
<form ng-submit="expression"></form>
Supportato dall'elemento <form>.
Valori dei parametri
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. |