Angular 2 ngOnInit is not called when routerlink changes

前端 未结 3 1234
故里飘歌
故里飘歌 2021-01-06 12:31

i have a menu bar that contain a list of menus loaded from express api and every menu is referenced to a page that have an alias wich will be the URL of tha

3条回答
  •  时光说笑
    2021-01-06 13:24

    When only a router parameter is changes but the base of the route stays the same, Angular reuses the component. ngOnInit() is only called once after a component is instantiated, but not when the route changes.

    You can inject the router and subscribe to it's events or params to get notified about route changes.

提交回复
热议问题