دستور ng-submit AngularJS

تعریف و استفاده

ng-submit این دستور مشخص می‌کند که کدام فایل باید در هنگام ارسال فرم اجرا شود.

اگر فرم action نداشته باشد، 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 clicked submit";
    $scope.myFunc = function () {
        $scope.myTxt = "You clicked submit!";
    }
});
</script>
</body>

Try It Yourself

Syntax

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

Affected <form> Element Support.

Parameters

Parameters Description
expression Function to be called when submitting a form, or an expression to be calculated, which should return a function call.