ng-submit calls custom function
Description
The following code shows how to use ng-submit to call custom function.
Example
<!--from w ww . j a v a 2s . co m-->
<!doctype html>
<html ng-app="myApp" >
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js"></script>
<script>
var app = angular.module('myApp', []);
app.controller('MainCtrl', function($scope) {
$scope.showAlert = function(q) {
console.log(q);
};
});
</script>
</head>
<body ng-controller="MainCtrl">
<form ng-submit="showAlert(q)">
<input ng-model="q">Press enter to submit
</form>
</body>
</html>