angular 2 - how to hide nav bar in some components

后端 未结 9 742
半阙折子戏
半阙折子戏 2020-12-04 16:07

I am created nav bar separately in nav.component.html ,how to hide nav bar in some components like login.component.

nav.component.html

9条回答
  •  隐瞒了意图╮
    2020-12-04 16:23

    You can use ngIF directive on components where nav is located

       
    

    after you get the current route:

      this.router.events.subscribe(event => {
      if (event.constructor.name === "NavigationEnd") {
        this.name = (event).url.split("/").slice(-1)[0];
        this.isLogin = this.currentRoute === 'login';
      }
    })
    

提交回复
热议问题