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