AngularJS ng-click Directive
Increase the count variable by one, each time the button is clicked:
Definition and Usage
The ng-click directive tells AngularJS what to do when an HTML element is clicked.
Supported by all HTML elements.
Parameter Values
More examples.
Execute a function, in AngularJS, when a button is clicked:
COLOR PICKER
Contact Sales
If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: [email protected]
Report Error
If you want to report an error, or if you want to make a suggestion, send us an e-mail: [email protected]
Top Tutorials
Top references, top examples, get certified.
- {{navItem.extra.text}} {{navItem.name}}
- AngularJS Tutorial
- AngularJS Directives
- AngularJS Functions
- AngularJS Filters
- AngularJS Examples
- AngularJS Interview Questions
- Angular ngx Bootstrap
- AngularJS Cheat Sheet
- AngularJS PrimeNG
- Web Technology
AngularJS ng-click Directive
The ng-click Directive in AngluarJS is used to apply custom behavior when an element is clicked. It can be used to show/hide some element or it can pop up an alert when the button is clicked.
Parameter Value:
- expression: It specifies when the particular element is clicked then the specific expression will be evaluated.
Supported tag: It is supported by all the elements in HTML.
Example 1: This example illustrates the implementation of the ng-click Directive to display an alert message after clicking the element.
ng-click Directive
Example 2: This example illustrates the implementation of the ng-click Directive to display some content after clicking the element.
- Web Technologies
- AngularJS-Directives
IMAGES
VIDEO