Hide and Show angular 4 component depending on route

后端 未结 5 1734
渐次进展
渐次进展 2021-02-01 19:03

Hi there Im not sure if this is possible... basically I want to be able to show a component but only if the route matches and hide a component if the route matches Ive tried thi

5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-01 19:12

    Take a look at this Angular Rounting guide.

    You'll need a method called canActivate, this mehtod return a boolean and its in a service.

    This I what works form me:

    {path : 'getIn', component: GetinComponent , canActivate: [GetInService] }
    

提交回复
热议问题