How to Reload or Re-Render the Entire Page Using Angularjs

How to reload or re-render the entire page using AngularJS

For the record, to force angular to re-render the current page, you can use:

$route.reload();

According to AngularJS documentation:

Causes $route service to reload the current route even if $location hasn't changed.

As a result of that, ngView creates new scope, reinstantiates the controller.

How to reload a page using Angularjs?

Be sure to include the $route service into your scope and do this:

$route.reload();

See this:

How to reload or re-render the entire page using AngularJS

Angularjs re-render the whole page [ionic]

You could user following if you are using UI-Router on Ionic

        $state.go($state.current, {}, {reload: true});

Or If you are using only Angular Routes, Use follwoing

        $route.reload()

How to reload a page once using angular or javascript

I don't understand your use case but there is lot of way to make what you want.

I propose you a way with localStorage.

Check if a localStorage exist. By default the key don't exist, so you create it and reload the page too.

After the refresh you check the same key (that exist now). So you don't reload the page and remove the key for the next time

ngOnInit() {
if (!localStorage.getItem('foo')) {
localStorage.setItem('foo', 'no reload')
location.reload()
} else {
localStorage.removeItem('foo')
}
}


Related Topics



Leave a reply



Submit