AngularJS ng-submitनिर्देश


उदाहरण

फ़ॉर्म सबमिट होने पर फ़ंक्शन चलाएँ:

<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>

परिभाषा और उपयोग

जब ng-submitफॉर्म जमा किया जाता है तो निर्देश एक फ़ंक्शन को चलाने के लिए निर्दिष्ट करता है।

यदि फॉर्म में वसीयत नहीं है तो action ng-submitफॉर्म को जमा होने से रोका जा सकता है।


वाक्य - विन्यास

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

<form> तत्व द्वारा समर्थित।


पैरामीटर मान

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.