Reputation: 55
I'm working on a small project in order to learn AngularJS. This project has two pages "/" and "/login". So, when not authenticated it redirects to "/login" and if authenticated to "/". Authentication process is handled by a NodeJS server and it works. I've implemented a simple authentication in controller.
if ((typeof $scope.token === "undefined") || ($scope.token == null))
$location.path("/login");
else
$location.path("/");
This piece of code, when I'm not authenticated and access "/" redirects me to "/login", but when I access "/#/" it shows the content of "/" even though I'm not authenticated.
So I wanted to know if there is a difference between "/" and "/#/", and why it is happening?
Upvotes: 1
Views: 70
Reputation:
URLs with #<anything>
are local to the browser, the hash and whatever is after it are never sent to the server upon request, nor is the page reloaded when the hash is appended or changed. It's useful for client-side triggers that can be shared directly in the URL.
Locally, you can access it's value with location.hash
(but in your case, it'd just be "/"
)
So the difference is that one is your /
URL without a hash, and /#/
is your URL with a hash that has "/"
as it's value.
Upvotes: 2