Make visible menu in Angular 4 after login

0

Good afternoon. I have an application in Angular 4, which performs a login by searching the parameters of a form in an API through an http request. The initial screen, where the login form appears, has a navbar and a footer, and in the navbar there is a button that displays the navigation menu. The problem is that I would like that button was not visible until the login has been successful. I show here the structure of the app.component.ts:

<body>
<header>
    <nav>
      <menu></menu>  
    </nav>            
</header>
<main>
    <router-outlet></router-outlet>
</main>
<footer>
    <pie></pie>
</footer>

And here it looks like it shows in the browser:

Thank you very much in advance.

    
asked by AntonioMP87 08.12.2017 в 14:58
source

1 answer

0

You should separate features by components , so that the login was a separate component that after making the corresponding http request redirected ( Angular routing functionality ) to a new component that contains the contents of your application with the menu header that you indicate.

Even so, if you wanted to simply visualize / hide this header you could use a token system for the login so that with a ngIf you will control if there is a session token (the user has been authenticated) to show or not the menu.

    
answered by 08.12.2017 / 15:43
source