VOOZH about

URL: https://www.geeksforgeeks.org/angular-js/angularjs-ng-click-directive/

⇱ AngularJS ng-click Directive - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

AngularJS ng-click Directive

Last Updated : 1 Aug, 2022

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. 

Syntax:

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

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. 

Output:

👁 Image
ng-click Directive

Example 2: This example illustrates the implementation of the ng-click Directive to display some content after clicking the element. 

Output:

👁 Image
ng-click Directive
Comment

Explore