Angularjs Examples

AJS Examples


AngularJS ng-Click Directive

The AngularJS ng-click directive is used execute a method or expression.

Syntax

<div ng-click="counter()"></div>

AngularJS ng-Click Directive Example

<html>
<head>
<title>My first AngularJS ng-click Directive code</title>
<Script SRC="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js">
</Script>
<Script>
//Defining Controller Using Standard Javascrip Object Constructor
function CustomerController($scope) {
	$scope.count = 0;
}
</Script>
</head>
<body>
<div ng-app="">
<div ng-controller="CustomerController"> 

<input type="button" ng-click="count = count + 1" value="counter">   
<p ng-bind="count"> </p> 

</div>
</div>
</body>
</html>
See Live Example