Angular 2 reload route on param change

后端 未结 13 1128
小鲜肉
小鲜肉 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

    this.route.paramMap.subscribe(params => {
      //fetch your new parameters here, on which you are switching the routes and call ngOnInit()
      this.ngOnInit();
     });
    

    You just need to call ngOnInit() from inside the paramMap and it will initialise the whole page with newly loaded data.

提交回复
热议问题