Unable to hide the navigation bar in login page in angular 2

烈酒焚心 提交于 2020-01-03 02:24:11

问题


I am trying to implement a sample app in Angular using Angular Material and Angular Flex Layout.

I have implemented a navigation bar which i want to hide in login page and visible in all pages in the application.

I have created a service with the name showmenu.service.ts where I have declared a variable and assigned as boolean value. Also defined two functions show() and hide()

I am not getting any error, but I am unable to hide the navigation bar in my login page .

Please access my sample code here ..https://stackblitz.com/edit/sample-login-bm7t1c?file=app%2Fshowmenu.service.ts


回答1:


I made lot of changes to resolve it.

Please take a look at this

working code


The changes are,

you need a click event for logout button instead of direct navigation

(click)="logout()"

and the logout method should be like below (to hide the menu and do navigation here).

logout()
  {
    this.showmenu.hide();
    this._router.navigate(['myform']);
  }

also I don't know why [hidden] is not working for you. So i just use the visible property in fxShow to solve your problem.

 fxShow="{{!showmenu.visible}}" 

Finally we did it :)



来源:https://stackoverflow.com/questions/50387896/unable-to-hide-the-navigation-bar-in-login-page-in-angular-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!