@@ -5,14 +5,15 @@ import {
55 ComponentRef ,
66} from '@angular/core' ;
77import {
8- Overlay ,
9- OverlayState ,
10- OverlayRef ,
118 ComponentType ,
129 ComponentPortal ,
10+ Overlay ,
1311 OverlayModule ,
12+ OverlayRef ,
13+ OverlayState ,
1414 PortalModule ,
1515 OVERLAY_PROVIDERS ,
16+ MdLiveAnnouncer ,
1617} from '@angular2-material/core' ;
1718import { CommonModule } from '@angular/common' ;
1819import { MdSnackBarConfig } from './snack-bar-config' ;
@@ -35,7 +36,8 @@ export class MdSnackBar {
3536 /** A reference to the current snack bar in the view. */
3637 private _snackBarRef : MdSnackBarRef < any > ;
3738
38- constructor ( private _overlay : Overlay ) { }
39+ constructor ( private _overlay : Overlay ,
40+ private _live : MdLiveAnnouncer ) { }
3941
4042 /**
4143 * Creates and dispatches a snack bar with a custom component for the content, removing any
@@ -48,8 +50,9 @@ export class MdSnackBar {
4850 }
4951 let overlayRef = this . _createOverlay ( ) ;
5052 let snackBarContainer = this . _attachSnackBarContainer ( overlayRef , config ) ;
51-
52- return this . _attachSnackbarContent ( component , snackBarContainer , overlayRef ) ;
53+ let mdSnackBarRef = this . _attachSnackbarContent ( component , snackBarContainer , overlayRef ) ;
54+ this . _live . announce ( config . announcementMessage , config . politeness ) ;
55+ return mdSnackBarRef ;
5356 }
5457
5558
@@ -58,7 +61,9 @@ export class MdSnackBar {
5861 */
5962 open ( message : string , actionLabel : string ,
6063 config : MdSnackBarConfig ) : MdSnackBarRef < SimpleSnackBar > {
64+ config . announcementMessage = message ;
6165 let simpleSnackBarRef = this . openFromComponent ( SimpleSnackBar , config ) ;
66+ simpleSnackBarRef . instance . snackBarRef = simpleSnackBarRef ;
6267 simpleSnackBarRef . instance . message = message ;
6368 simpleSnackBarRef . instance . action = actionLabel ;
6469 return simpleSnackBarRef ;
@@ -87,7 +92,6 @@ export class MdSnackBar {
8792 let portal = new ComponentPortal ( component ) ;
8893 let contentRef = container . attachComponentPortal ( portal ) ;
8994 let snackBarRef = < MdSnackBarRef < T > > new MdSnackBarRef ( contentRef . instance , overlayRef ) ;
90- snackBarRef . instance . snackBarRef = snackBarRef ;
9195
9296 this . _snackBarRef = snackBarRef ;
9397 return snackBarRef ;
@@ -118,7 +122,7 @@ export class MdSnackBarModule {
118122 static forRoot ( ) : ModuleWithProviders {
119123 return {
120124 ngModule : MdSnackBarModule ,
121- providers : [ MdSnackBar , OVERLAY_PROVIDERS ]
125+ providers : [ MdSnackBar , OVERLAY_PROVIDERS , MdLiveAnnouncer ]
122126 } ;
123127 }
124128}
0 commit comments