user3494179
user3494179

Reputation: 373

AngularJS: append param to url and refresh page

How can I do this in Angular:

window.location.href = window.location.href + "/?id = 123";

So append new paramater to the end of the url and refresh the page(without loading it from cache).

Upvotes: 1

Views: 10378

Answers (2)

Mehdi Betari
Mehdi Betari

Reputation: 9

Use $window :

$window.location.href = $location.path() + "/?id = 123";

Or use $location :

$location.url($location.path() + "/?id = 123");

The results are same, only view is reload by angular, this is not a force refresh by the browser.

Upvotes: 0

Chanthu
Chanthu

Reputation: 1794

You can use $location for that.

Example: $location.search('id','123)

That is going to append ?id=123 to the current page url and do a soft refresh.

Then to do a hard refresh you can do location.reload()

Upvotes: 4

Related Questions