AngularJS ng-Submit Directive

AngularJS ng-Submit Directive: The ng-submit directive is used to binds the angular JS expressions to submit events. It just prevents the default actions only if the form does not contain action,data-action,x-action attributes. The ng-submit directive executes at a priority level 0.

AngularJS ng-Submit Directive Syntax


ng-submit Directive Arguments 

Param type Details
ngSubmit expression Expression to eval. (Event object is available as $event)

AngularJS ng-submit Directive Example

<!doctype html>
<html lang="en">
<meta charset="UTF-8">
<title>Example - example-ng-submit-production</title>
<script src="//"></script>
<body ng-app="submitExample">
angular.module('submitExample', [])
.controller('ExampleController', ['$scope', function($scope) {
$scope.list = [];
$scope.text = 'hello';
$scope.submit = function() {
if ($scope.text) {
$scope.text = '';
<form ng-submit="submit()" ng-controller="ExampleController">
Enter text and hit enter:
<input type="text" ng-model="text" name="text" />
<input type="submit" id="submit" value="Submit" />

AngularJS ng-submit Example OutputAngular JS ng-submit Example Output