WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

AngularJS ng-click Directive


Example

Increase the tally variable by one, each time the catch is clicked:

<button ng-click="count = tally + 1" ng-init="count=0">OK</button>
Try it yourself »

Definition and Usage

The ng-click order instructs AngularJS when a HTML component is clicked.


Syntax

<element ng-click="expression"></element>

Supported by all HTML elements.


Parameter Values

Value Description
expression An articulation to execute when a component is clicked.

More examples

Example

Execute a capacity, in AngularJS, when a catch is clicked:

<body ng-app="myApp">

<div ng-controller="myCtrl">
    <button ng-click="myFunc()">OK</button>
    <p>The catch has been clicked {{count}} times.</p>
</div>

<script>
angular.module('myApp', [])
.controller('myCtrl', ['$scope', function($scope) {
    $scope.count = 0;
    $scope.myFunc = work() {
        $scope.count++;
    };
}]);
</script>

</body>
Try it yourself »