0

I saw here in the Angular js documentation that

A path should always begin with forward slash (/); the $location.path() setter will add the forward slash if it is missing.

This is so different from what I do previously, which does not need the forward slash. Hence I wonder what is really the significance of the forward slash, and does it depend on if I use the html5 mode? Is there server side ramification? (e.g. if my server would serve a url specific page instead of directing all url to index.html?)

1 Answers1

2

pushState URL's always want to follow paths from the root path of the application.

For example --- adding an href property with a relative path using a pushState application, you will append to the current URL rather than pointing to a new one.

If we are at /test/123 and want to go to /test/456 we precede the URL with a foward slash to signify "from the root path"

<a href="/test/456"></a>

because...

<a href="test/456"></a>

Will bring you too /test/123/test/456 which was a relative URL --- and it is possible in some contexts you may want to use that kind of functionality.

Dan Kanze
  • 18,485
  • 28
  • 81
  • 134