Angular 2 reload route on param change

后端 未结 13 1103
小鲜肉
小鲜肉 2020-12-07 13:15

I am currently writing my first Angular 2 Application. I have an OverviewComponent which has the following simple template:

13条回答
  •  自闭症患者
    2020-12-07 13:46

    You can change the routeReuseStrategy directly at the component level:

    constructor(private router: Router) {
    
          // force route reload whenever params change;
          this.router.routeReuseStrategy.shouldReuseRoute = () => false;
    
    }
    

    Likewise, the reuse strategy can be changed globally.

    This does not necessarily address your problem directly but seeing how this question is the first search result for "angular 2 reload url if query params change" it might save the next person from digging through the github issues.

提交回复
热议问题