Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
95
rated 0 times [  96] [ 1]  / answers: 1 / hits: 17122  / 9 Years ago, thu, april 16, 2015, 12:00:00

I am trying to reload the page and redirect it to another one,
or just redirect it to another one but I can't do that by



window.location.href


or



windown.location


as I have an Angular Single Page app which catches the route and instead of reloading the page opens the partials directly



I did try -



window.location.reload(true)


but it reloads the page and cannot change the url
I have also tried -



window.location.assign


and



window.location.replace


Is there any way to do this?


More From » angularjs

 Answers
11

There are three cases where AngularJS will perform a full page reload:



Links that contain target element



Example:



<a href=/ext/link?a=b target=_self> link  </a>


Absolute links that go to a different domain
Example:



<a href=http://angularjs.org/>link</a>


Links starting with '/' that lead to a different base path when base is defined
Example:



<a href=/not-my-base/link>link</a>


Updated:



Using javascript:



The $location service allows you to change only the URL; it does not allow you to reload the page. When you need to change the URL and reload the page or navigate to a different page, please use a lower level API: $window.location.href.



See:



https://docs.angularjs.org/guide/$location



https://docs.angularjs.org/api/ng/service/$location


[#67049] Tuesday, April 14, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
nestorjarettg

Total Points: 451
Total Questions: 108
Total Answers: 108

Location: Rwanda
Member since Thu, Feb 10, 2022
2 Years ago
;