Angular2 router 2.0.0 not reloading components when same url loaded with different parameters?

前端 未结 5 668
轮回少年
轮回少年 2020-11-27 06:34

I have this in my .routing.ts file

export const routing = RouterModule.forChild([
{
    path: \'page/:id\',
    component: PageComponent
}]);
5条回答
  •  遥遥无期
    2020-11-27 07:10

    Angular 9

    I have used the following and it worked.

      onButtonClick() {
         this.router.routeReuseStrategy.shouldReuseRoute = function () {
         return false;
         }
       this.router.onSameUrlNavigation = 'reload';
       this.router.navigate('/myroute', { queryParams: { index: 1 } });
    

    }

    In addition it also works for path params.

提交回复
热议问题