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:

Get Certified

COLOR PICKER

colorpicker

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

Improve your Coding Skills with Practice

 alt=

What kind of Experience do you want to share?

IMAGES

  1. AngularJs onclick

    ng click variable assignment

  2. Angular Tutorial || Angular ng-switch and ng-variables: A Complete Guide || Creating Basic APIs

    ng click variable assignment

  3. Inline if/else statement ngClick AngularJS

    ng click variable assignment

  4. AngularJS ng-click Event Function with Example

    ng click variable assignment

  5. AngularJS的ng-click传参-CSDN博客

    ng click variable assignment

  6. ng-click-outside

    ng click variable assignment

VIDEO

  1. Solving a Formula Problem in Algebra