We use $location service or $window to redirect to a new URL. $location exposes the URL to the browsers address bar and makes it available to the application. It reflects the changes either side ,i.e. synchronizes the changes and maintains it between the browser’s URL and itself by keeping a watch in the URL.
We should use $location whenever we want to change the current URL in the browser or there is a change in the current URL and your applications need to monitor or react to that change.
With $location, there are two ways of using it :
1. $location.path(URL); Syntax:
2. $location.url(URL); Syntax:
The $location does not do the full page reload. For reloading the page after changing the URL, we need to use the $window.location.href ( it will refresh the page ). Syntax: