Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 1x 1x 1x 1x 1x 1x 4x 5x 5x 5x 5x 2x 10x 2x | import { Component, OnDestroy, OnInit } from '@angular/core'; import { NavigationEnd, Router, RouterOutlet } from '@angular/router'; import { MenuComponent } from './layout/menu/menu.component'; import { NotificationComponent } from './layout/notification/notification.component'; import { filter, Subject, takeUntil } from 'rxjs'; import { MatMenuModule } from '@angular/material/menu'; @Component({ selector: 'app-root', imports: [RouterOutlet, MenuComponent, NotificationComponent, MatMenuModule], templateUrl: './app.component.html', styleUrl: './app.component.scss' }) export class AppComponent implements OnInit, OnDestroy { public showMainMenu = true; private destroy$: Subject<boolean> = new Subject<boolean>(); title = 'MyJobs'; constructor(private router: Router) {} public ngOnInit() :void { this.router.events .pipe( // unsubscribe on component destruction takeUntil(this.destroy$), filter(event => event instanceof NavigationEnd) ) .subscribe(() => { // main menu must not be shown on homepage this.showMainMenu = !this.router.url.match(/^\/$/); }); } public ngOnDestroy(): void { // emit to Subject to unsubscribe from observables this.destroy$.next(true); } } |