English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

AngularJS ng-click Instruction

AngularJS Reference Manual

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.staticfile.org/angular.js/1.4.6/angular.min.js"></script>
</head>
<body ng-app="">
<p>Click button:</p>
<button ng-click="count = count + 1" ng-init="count=0">OK</button>
The button has been clicked {{count}} times./p>
In the example, the variable "count" will automatically increase each time the button is clicked. 1。</p>
</body>
</html>
Test to see ‹/›

Definition and Usage

ng-click The directive tells AngularJS what operation needs to be performed after the HTML element is clicked.

Syntax

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

All HTML elements support it.

Parameter Value

ValueDescription
expressionThe expression to be executed after the element is clicked.

AngularJS Reference Manual