angular - Angular2+ apply class to element outside of component -


long story short want display side-bar beside router-outlet depending on component being rendered, have looks this:

<div class="content-wrapper clearfix" [class.show-sidebar]='showsidebar'>      <div class="router-wrapper">          <router-outlet></router-outlet>      </div>      <div class="sidebar-wrapper">          <sidebar></sidebar>      </div>   </div> 

so components need make sidebar go away, i'm not sure cleanest approach is, first thought bind class field in service injected components need hide/show sidebar work doesn't seem right me...

you can make use of router outlet events

<router-outlet (activate)="onactivate($event)"></router-outlet> 

and in component containing router-outlet implement onactivate method:

public onactivate(event : any) {     console.log(event); // here hold of component , can make variable true false , use ngif or hidden show or hide navbar } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -