Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

AngularJS ng-submit Directive

AngularJS ng-submit Instruction

AngularJS Reference Manual AngularJS Reference Manual


AngularJS Examples

Execute a function after the form is submitted:

<

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 clicked submit yet!";

    $scope.myFunc = function () {

        $scope.myTxt = "You clicked submit!";

    }

});

<

/script

<

/body

Try it »


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

elements support this attribute.

Parameter value

Value Description
expression After the form is submitted, the function will be called, or an expression will be executed that returns a function call.

AngularJS Reference Manual AngularJS Reference Manual