undefinedfix
Sign in

How to refresh the current page in angular2

toondv edited in Wed, 21 Jul 2021

Refresh in angularjs$ route.reload (); the cost of this refresh is higher than that of direct refresh window.location The cost is small.

I don't know if there is a corresponding method to refresh in angular2

7 Replies
hollowKnightAWS
commented on Wed, 21 Jul 2021

If there is such a demand, I think only location.reload Let's go.

yched
commented on Wed, 21 Jul 2021

router.renavigate ()

Martin
commented on Thu, 22 Jul 2021

First of all, in the ang route, I do the jump without refresh. Usually I do the refresh myself by using location. If there are other ways, please let me know,

Andrea
commented on Thu, 22 Jul 2021

There is no such method in angular. If necessary, it can only be used window.location.reload ();

armen10
commented on Thu, 22 Jul 2021

Why not re request the data,

user282
commented on Thu, 22 Jul 2021
$state.reload();
BlueDragon709
commented on Thu, 22 Jul 2021

It can be as follows:

this.router.onSameUrlNavigation = 'reload';
    this.router.navigateByUrl(this.router.url).then(() => {
      this.router.onSameUrlNavigation = 'ignore';
    });

If resolve is used, the following can be added to routes:

runGuardsAndResolvers: 'always'
lock This question has been locked and the reply function has been disabled.