import { ChangeDetectorRef , Component , OnDestroy } from '@angular/core' ; import { MediaMatcher } from '@angular/cdk/layout' ; @ Component ( { selector : 'app-root' , templateUrl : './app.component.html' , styleUrls : [ './app.component.css' ] } ) export class AppComponent implements OnDestroy { title = 'Company structure' ; mobileQuery : MediaQueryList ; readonly mobileQueryListener : ( ) => void ; constructor ( changeDetectorRef , media ) { this . mobileQuery = media . matchMedia ( '(max-width: 600px)' ) ; this . mobileQueryListener = ( ) => changeDetectorRef . detectChanges ( ) ; this . mobileQuery . addListener ( this . mobileQueryListener ) ; } ngOnDestroy ( ) { this . mobileQuery . removeListener ( this . mobileQueryListener ) ; } }