How to link within the same page using angular js?

How to link within the same using angular js ? In html we use href="#top to go to element which have id=“top”.

I’ve pasted a response from StackOverflow below:

If you take a look at https://docs.angularjs.org/guide/$location and its HTML Link Rewriting section, you’ll see that links are not rewritten in the following:

Links that contain target element
Example: <a href="/ext/link?a=b" target="_self">link</a>

So, all you have to do is add the target attribute to your links, like so:

<a href="#anchorLinkID" target="_self">Go to inpage section</a>

Angular defaults to the browser and since its an anchor link and not a different base url, the browser scrolls to the correct location, as desired.

Thank you Sir for your help.