0

I see this syntax of links in AngularJS applications:

<a href="/#/something">something</a>

Why is there the '/#/' in the link, and what does it achieve? I think I might have also seen a version with a bang in it, something like

<a href="/!#/login"> 

or

<a href="/#!/login">

What is the purpose of the !?

Thank you!

Lew
  • 1,431
  • 1
  • 16
  • 22
  • possible duplicate of [What's the shebang/hashbang (#!) in Facebook and new Twitter URLs for?](http://stackoverflow.com/questions/3009380/whats-the-shebang-hashbang-in-facebook-and-new-twitter-urls-for) –  Nov 11 '14 at 18:54

2 Answers2

2

The purpose of the '#' or the '!' in a link used with angular (and many other JavaScript libraries) is for client-side routing.

Take a look at the $location service documentation here for more information.

MDiesel
  • 2,647
  • 12
  • 14
1

The hashtag is in the link for non-HTML5 browsers to prevent the browser from making the actual href call. It's actually not needed for most browsers these days.

nairys
  • 333
  • 3
  • 9