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.