无法以角度2隐藏登录页面中的导航栏 [英] Unable to hide the navigation bar in login page in angular 2

查看:93
本文介绍了无法以角度2隐藏登录页面中的导航栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Angular Material Angular Flex在 Angular 中实现示例应用程序 布局.

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.

我创建了一个名称为 showmenu.service.ts 的服务,在该服务中我声明了一个变量并将其分配为布尔值.还定义了两个功能 show() hide()

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 .

请在此处访问我的示例代码.. https ://stackblitz.com/edit/sample-login-bm7t1c?file = app%2Fshowmenu.service.ts

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

推荐答案

我进行了很多更改来解决它.

I made lot of changes to resolve it.

请看看这个

更改为

您需要注销按钮的点击事件,而不是直接导航

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']);
  }

我也不知道为什么[hidden]对您不起作用.所以我只是使用fxShow中的visible属性来解决您的问题.

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}}" 

最后我们做到了 :)

这篇关于无法以角度2隐藏登录页面中的导航栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆