Question

A lot of the time in our AngularJS applications, we'll have URLs hard coded as in the tutorial presented on the official Angular site, eg:

<a href="#/phones/{{phone.id}}">

Couple of questions in regards to this.

  • If moving from #/ to pushState, does one manually have to go and rewrite every single URL in their application? In this case, we'd have to rewrite the above to `

  • What about reverse compatibility with older browsers? If we go and rewrite all of our URLs, will Angular know to drop a # in front of URLs on its own, or is this something the developer needs to handle?

Wish there was more pushState documentation out there, this is a bit confusing for a new comer.

Était-ce utile?

La solution

  1. Yes you have to manually change all those links.
  2. Yes, angular will automatically add the # if there's no support for the HTML5 history API.

P.S. You never needed the # there to begin with. Angular adds that automatically for you.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top