Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

ng
click
webdevelopment
angular
communitycreator

What is ng-click in Angular?

Saad Akbar

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Angular is a web development framework invented by Google. Angular is used to handle the front-endthe screen visible to the user of web applications, and designed to make it easy to reuse code.

What is ng-click in Angular?

ng-click is an attribute of an HTMLHyperText Markup Language element that can be used for the customized components in Angular.

We use this attribute to detect if an element is clicked and tracks the mouse’s cursor.

ng-click takes a function as an attribute and calls it whenever an element is clicked. This function controls the whole flow of an application such as:

  • What to do when a user clicks something.
  • Where to redirect the user.
  • What messages to show if something is clicked.

Code

The following code explains what the ng-click attribute does for an HTML element.

Explanation

The ng-click attribute detects a click on a button that says "Login", and when that button is clicked, ng-click calls the login() function.

RELATED TAGS

ng
click
webdevelopment
angular
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring