English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

AngularJS ng-submit directive

AngularJS Reference Manual

AngularJS Example

Execute function after form submission:

!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.staticfile.org/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>
<p>This example demonstrates the execution of AngularJS after the form is submitted.</p>/p>
<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
  $scope.myTxt = "You have not clicked submit!";
  $scope.myFunc = function() {
      $scope.myTxt = "You clicked submit!";
  }
});
</script>
</body>
</html>
Test and see ‹/›

Definition and Usage

ng-submit The 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

ValueDescription
expressionAfter the form is submitted, a function will be called, or an expression will be executed, and the expression returns the function call.

AngularJS Reference Manual