Submit form with ng-click

Description

The following code shows how to submit form with ng-click.

Example


<!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', []);
<!--   www .  ja  v  a 2s. c  om-->
app.controller('MainCtrl', function($scope) {
  $scope.showAlert = function(q) {
    console.log(q);
  }; 
});
  
  </script>
</head>
<body ng-controller="MainCtrl">
  <form>
    <input ng-model="q">
    <button ng-click="showAlert(q)">Search</button>
  </form>
</body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities