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
Post a Comment