diff --git a/src/lib/schematics/nav/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html b/src/lib/schematics/nav/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html index f71b7e702e9b..f12c995e4f7c 100644 --- a/src/lib/schematics/nav/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html +++ b/src/lib/schematics/nav/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html @@ -3,9 +3,9 @@ #drawer class="sidenav" fixedInViewport="true" - [attr.role]="isHandset ? 'dialog' : 'navigation'" - [mode]="(isHandset | async)!.matches ? 'over' : 'side'" - [opened]="!(isHandset | async)!.matches"> + [attr.role]="isHandset$ | async ? 'dialog' : 'navigation'" + [mode]="isHandset$ | async ? 'over' : 'side'" + [opened]="!(isHandset$ | async)"> Menu Link 1 @@ -20,7 +20,7 @@ aria-label="Toggle sidenav" mat-icon-button (click)="drawer.toggle()" - *ngIf="(isHandset | async)!.matches"> + *ngIf="isHandset$ | async"> menu Application Title diff --git a/src/lib/schematics/nav/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.ts b/src/lib/schematics/nav/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.ts index a39f2aa3af0f..b14541a89b6e 100644 --- a/src/lib/schematics/nav/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.ts +++ b/src/lib/schematics/nav/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.ts @@ -1,6 +1,7 @@ import { Component<% if(!!viewEncapsulation) { %>, ViewEncapsulation<% }%><% if(changeDetection !== 'Default') { %>, ChangeDetectionStrategy<% }%> } from '@angular/core'; import { BreakpointObserver, Breakpoints, BreakpointState } from '@angular/cdk/layout'; import { Observable } from 'rxjs'; +import { map } from 'rxjs/operators'; @Component({ selector: '<%= selector %>',<% if(inlineTemplate) { %> @@ -10,9 +11,9 @@ import { Observable } from 'rxjs'; #drawer class="sidenav" fixedInViewport="true" - [attr.role]="isHandset ? 'dialog' : 'navigation'" - [mode]="(isHandset | async)!.matches ? 'over' : 'side'" - [opened]="!(isHandset | async)!.matches"> + [attr.role]="isHandset$ | async ? 'dialog' : 'navigation'" + [mode]="isHandset$ | async ? 'over' : 'side'" + [opened]="!(isHandset$ | async)"> Menu Link 1 @@ -27,7 +28,7 @@ import { Observable } from 'rxjs'; aria-label="Toggle sidenav" mat-icon-button (click)="drawer.toggle()" - *ngIf="(isHandset | async)!.matches"> + *ngIf="isHandset$ | async"> menu Application Title @@ -53,6 +54,12 @@ import { Observable } from 'rxjs'; changeDetection: ChangeDetectionStrategy.<%= changeDetection %><% } %> }) export class <%= classify(name) %>Component { - isHandset: Observable = this.breakpointObserver.observe(Breakpoints.Handset); + + isHandset$: Observable = this.breakpointObserver.observe(Breakpoints.Handset) + .pipe( + map(result => result.matches) + ); + constructor(private breakpointObserver: BreakpointObserver) {} -} + + }