ng-submit
Directiva AngularJS
Ejemplo
Ejecute una función cuando se envíe el formulario:
<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>
Definición y uso
La ng-submit
directiva especifica una función para ejecutar cuando se envía el formulario.
Si el formulario no tiene una action
ng-submit
voluntad evitará que se envíe el formulario.
Sintaxis
<form ng-submit="expression"></form>
Compatible con el elemento <form>.
Valores paramétricos
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. |