В самом шаблоне пропишем ngIf
<header *ngIf="hasHeader" class="header"></header>
<aside *ngIf="hasAside" class="aside"></aside>
<router-outlet></router-outlet>
Слушаем изменения роутера в app.component
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
}
})
}
}