AngularJS change the default behavior of the anchor tag or <a> element.
In HTML <a> tag reload the page when its href attribute is empty, but AngularJS ignore the page reloading when a user clicks on the anchor <a> tag with href attribute is empty.
Syntax for <a> Anchor directive in AngularJS:
Sample coding for <a> Anchor directive in AngularJS:
The <a> tag inside HTML:
The <a> tag inside AngularJS:
Code Explanation for <a> Anchor directive in AngularJS:
The <a> tag with empty href attribute is defined inside the HTML Document.
The ng-app=”” is used to create the root element (div) for the AngularJS Application.
The <a> tag with empty href attribute is defined inside the AngularJS Application.
Sample Output for <a> Anchor directive in AngularJS:
When user try to click the anchor tag inside the HTML that will be reload the same page.
When user try to click the anchor tag inside the AngularJS, there is no action for the event.