Articles → ANGULAR.JS → Ng-Click In Angular.JS
Ng-Click In Angular.JS
Purpose
Syntax
<element ng-click="method()"/>
Example
<!DOCTYPE html>
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script type="text/javascript">
var app = angular.module('app', []);
app.controller('myController', function($scope) {
$scope.ClickMe = function() {
alert("Click me");
}
});
</script>
</head>
<body>
<div ng-app="app" ng-controller="myController">
<button ng-click="ClickMe()">Click me</button>
</div>
</body></html>
Output
Click to Enlarge