Lew
Lew

Reputation: 1461

What does this link syntax "/#/ - mean in AngularJS

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!

Upvotes: 0

Views: 72

Answers (2)

nairys
nairys

Reputation: 343

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.

Upvotes: 1

MDiesel
MDiesel

Reputation: 2667

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.

Upvotes: 2

Related Questions