What is ng-click in Angular?
Angular is a web development framework invented by Google. Angular is used to handle the
What is ng-click in Angular?
ng-click is an attribute of an
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.