Answer the question
In order to leave comments, you need to log in
How to enable or disable a block on a page?
Good afternoon.
Question on the second angular.
There is a main component app.component
In it is a template:
<header class="header"></header>
<aside class="aside"></aside>
<router-outlet></router-outlet>
Answer the question
In order to leave comments, you need to log in
In the template itself, write ngIf
<header *ngIf="hasHeader" class="header"></header>
<aside *ngIf="hasAside" class="aside"></aside>
<router-outlet></router-outlet>
import {Router} from '@angular/router';
export class AppComponent {
hasHeader: boolean = true
hasAside: boolean = true
constructor(
private _router: Router
) { }
ngOnInit() {
this._router.events
.subscribe(params => {
let path = params.url.split('/')[1]
if (path == 'auth') {
this.hasHeader = false
this.hasAside = false
} else {
this.hasHeader = true
this.hasAside = true
}
})
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question