@@ -22,7 +22,7 @@ import {
2222 NgZone ,
2323 OnDestroy ,
2424 Inject ,
25- ChangeDetectorRef ,
25+ ChangeDetectorRef , ContentChild ,
2626} from '@angular/core' ;
2727import { animate , state , style , transition , trigger , AnimationEvent } from '@angular/animations' ;
2828import { Directionality , coerceBooleanProperty } from '../core' ;
@@ -31,6 +31,7 @@ import {ESCAPE} from '../core/keyboard/keycodes';
3131import { first , takeUntil , startWith } from '../core/rxjs/index' ;
3232import { DOCUMENT } from '@angular/platform-browser' ;
3333import { merge } from 'rxjs/observable/merge' ;
34+ import { Subject } from 'rxjs/Subject' ;
3435
3536
3637/** Throws an exception when two MdDrawer are matching the same position. */
@@ -47,6 +48,20 @@ export class MdDrawerToggleResult {
4748 constructor ( public type : 'open' | 'close' , public animationFinished : boolean ) { }
4849}
4950
51+
52+ @Component ( {
53+ moduleId : module . id ,
54+ selector : 'md-drawer-content, mat-drawer-content' ,
55+ template : '<ng-content></ng-content>' ,
56+ host : {
57+ 'class' : 'mat-drawer-content' ,
58+ } ,
59+ changeDetection : ChangeDetectionStrategy . OnPush ,
60+ encapsulation : ViewEncapsulation . None ,
61+ } )
62+ export class MdDrawerContent { }
63+
64+
5065/**
5166 * <md-drawer> component.
5267 *
@@ -57,7 +72,7 @@ export class MdDrawerToggleResult {
5772@Component ( {
5873 moduleId : module . id ,
5974 selector : 'md-drawer, mat-drawer' ,
60- templateUrl : 'drawer.html ' ,
75+ template : '<ng-content></ng-content> ' ,
6176 animations : [
6277 trigger ( 'transform' , [
6378 state ( 'open, open-instant' , style ( {
@@ -116,7 +131,13 @@ export class MdDrawer implements AfterContentInit, OnDestroy {
116131 set align ( value ) { this . position = value ; }
117132
118133 /** Mode of the drawer; one of 'over', 'push' or 'side'. */
119- @Input ( ) mode : 'over' | 'push' | 'side' = 'over' ;
134+ @Input ( )
135+ get mode ( ) { return this . _mode ; }
136+ set mode ( value ) {
137+ this . _mode = value ;
138+ this . _modeChanged . next ( ) ;
139+ }
140+ private _mode : 'over' | 'push' | 'side' = 'over' ;
120141
121142 /** Whether the drawer can be closed with the escape key or not. */
122143 @Input ( )
@@ -155,6 +176,8 @@ export class MdDrawer implements AfterContentInit, OnDestroy {
155176 /** @deprecated */
156177 @Output ( 'align-changed' ) onAlignChanged = new EventEmitter < void > ( ) ;
157178
179+ _modeChanged = new Subject ( ) ;
180+
158181 get isFocusTrapEnabled ( ) {
159182 // The focus trap is only enabled when the drawer is open in any mode other than side.
160183 return this . opened && this . mode !== 'side' ;
@@ -293,6 +316,7 @@ export class MdDrawer implements AfterContentInit, OnDestroy {
293316 }
294317}
295318
319+
296320/**
297321 * <md-drawer-container> component.
298322 *
@@ -316,6 +340,8 @@ export class MdDrawer implements AfterContentInit, OnDestroy {
316340export class MdDrawerContainer implements AfterContentInit {
317341 @ContentChildren ( MdDrawer ) _drawers : QueryList < MdDrawer > ;
318342
343+ @ContentChild ( MdDrawerContent ) _content : MdDrawerContent ;
344+
319345 /** The drawer child with the `start` position. */
320346 get start ( ) { return this . _start ; }
321347
@@ -357,6 +383,7 @@ export class MdDrawerContainer implements AfterContentInit {
357383 this . _drawers . forEach ( ( drawer : MdDrawer ) => {
358384 this . _watchDrawerToggle ( drawer ) ;
359385 this . _watchDrawerPosition ( drawer ) ;
386+ this . _watchDrawerMode ( drawer ) ;
360387 } ) ;
361388 } ) ;
362389 }
@@ -405,6 +432,14 @@ export class MdDrawerContainer implements AfterContentInit {
405432 first . call ( this . _ngZone . onMicrotaskEmpty ) . subscribe ( ( ) => this . _validateDrawers ( ) ) ) ;
406433 }
407434
435+ /** Subscribes to changes in drawer mode so we can run change detection. */
436+ private _watchDrawerMode ( drawer : MdDrawer ) : void {
437+ if ( drawer ) {
438+ takeUntil . call ( drawer . _modeChanged , this . _drawers . changes ) . subscribe (
439+ ( ) => this . _changeDetectorRef . markForCheck ( ) ) ;
440+ }
441+ }
442+
408443 /** Toggles the 'mat-drawer-opened' class on the main 'md-drawer-container' element. */
409444 private _setContainerClass ( isAdd : boolean ) : void {
410445 if ( isAdd ) {
0 commit comments