<a ng-href="#" class="navbar-brand" title="home" data-translate>PORTAL_NAME</a>
I want to reload the page. How can I do this?
I want to reload the page. How can I do this? |
||||
|
You can use the
Then you can use it on the link like this:
This method will cause the current route to reload. If you however want to perform a full refresh, you could inject
As mentioned by JamesEddyEdwards and Dunc in their answers, if you are using angular-ui/ui-router you can use the following method to reload the current state / route. Just inject
|
|||||||||||||||||||||
|
And :
As a side note, i don't think $route.reload() actually reloads the page, but only the route. |
|||||||||||||||||
|
Similar to Alexandrin's answer, but using $state rather than $route: (From JimTheDev's SO answer here.)
|
||||
|
If using Angulars more advanced ui-router which I'd definitely recommend then you can now simply use:
Which is essentially doing the same as Dunc's answer. |
|||
|
Does the trick.
No need for routes or anything just plain old js |
|||||
|
It's easy enough to just use
You only need to use ng-href to protect the user from invalid links caused by them clicking before Angular has replaced the contents of the {{ }} tags. |
|||||
|
On Angular 1.5 - after trying some of the above solutions wanting to reload only the data with no full page refresh, I had problems with loading the data properly. I noticed though, that when I go to another route and then I return back to the current, everything works fine, but when I want to only reload the current route using
and in the module config, add another
and it works just fine for me. It does not refresh the whole page, but only causes the current controller and template to reload. I know it's a bit hacky, but that was the only solution I found. |
||||
|