I am basically able to completely hide a component, but I do not know how I can hide or show an element of a component.
export class AppComponent {
headerFooterVisible: boolean;
constructor(private router: Router){
router.events.subscribe(e => {
if(e instanceof NavigationEnd){
if(e.urlAfterRedirects != '/'){
this.headerFooterVisible= true;
}else{
this.headerFooterVisible= false;
}
}
});
}
name = 'Angular 4';
private activatedComponent;
onActivate(component){
this.activatedComponent = component;
}
<menu *ngIf="headerFooterVisible"></menu>
<router-outlet (activate)='onActivate($event)'></router-outlet>
<footer *ngIf="headerFooterVisible"></footer>
I want the variable {{headerFooterVisible}}
to be shown in each of my components in real time. how can I do it?
this is my code:
https://stackblitz.com/edit/angular-m6ffqn?file=app/another.component.ts