Browser page hardcore, then redirect to URL using javascript

advertisements

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?


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