विश्व का सबसे बड़ा हिंदी वेब डेवलपर साइट

AngularJS ng-submit Directive


Run a function when the form is submitted:

<body ng-app="myApp" ng-controller="myCtrl">

<form ng-submit="myFunc()">
    <input type="text">
    <input type="submit">


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!";
Try it yourself »

Definition and Usage

The ng-submit directive specifies a function to run when the form is submitted.

If the form does not have an action ng-submit will prevent the form from being submitted.


<form ng-submit="expression"></form>

Supported by the <form> element.

Parameter Values

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.