@@ -25,8 +25,6 @@ import {
2525 ViewEncapsulation ,
2626} from '@angular/core' ;
2727import { coerceBooleanProperty } from '@angular/cdk/coercion' ;
28- import { map } from '@angular/cdk/rxjs' ;
29- import { Observable } from 'rxjs/Observable' ;
3028import { Subscription } from 'rxjs/Subscription' ;
3129import { MdTab } from './tab' ;
3230import { merge } from 'rxjs/observable/merge' ;
@@ -131,9 +129,7 @@ export class MdTabGroup extends _MdTabGroupMixinBase implements AfterContentInit
131129 private _backgroundColor : ThemePalette ;
132130
133131 /** Output to enable support for two-way binding on `[(selectedIndex)]` */
134- @Output ( ) get selectedIndexChange ( ) : Observable < number > {
135- return map . call ( this . selectChange , event => event . index ) ;
136- }
132+ @Output ( ) selectedIndexChange : EventEmitter < number > = new EventEmitter ( ) ;
137133
138134 /** Event emitted when focus has changed within a tab group. */
139135 @Output ( ) focusChange : EventEmitter < MdTabChangeEvent > = new EventEmitter < MdTabChangeEvent > ( ) ;
@@ -157,16 +153,20 @@ export class MdTabGroup extends _MdTabGroupMixinBase implements AfterContentInit
157153 * a new selected tab should transition in (from the left or right).
158154 */
159155 ngAfterContentChecked ( ) : void {
160- // Clamp the next selected index to the bounds of 0 and the tabs length. Note the `|| 0`, which
161- // ensures that values like NaN can't get through and which would otherwise throw the
162- // component into an infinite loop (since Math.max(NaN, 0) === NaN).
156+ // Clamp the next selected index to the boundsof 0 and the tabs length.
157+ // Note the `|| 0`, which ensures that values like NaN can't get through
158+ // and which would otherwise throw the component into an infinite loop
159+ // (since Math.max(NaN, 0) === NaN).
163160 let indexToSelect = this . _indexToSelect =
164161 Math . min ( this . _tabs . length - 1 , Math . max ( this . _indexToSelect || 0 , 0 ) ) ;
165162
166163 // If there is a change in selected index, emit a change event. Should not trigger if
167164 // the selected index has not yet been initialized.
168165 if ( this . _selectedIndex != indexToSelect && this . _selectedIndex != null ) {
169166 this . selectChange . emit ( this . _createChangeEvent ( indexToSelect ) ) ;
167+ // Emitting this value after change detection has run
168+ // since the checked content may contain this variable'
169+ Promise . resolve ( ) . then ( ( ) => this . selectedIndexChange . emit ( indexToSelect ) ) ;
170170 }
171171
172172 // Setup the position for each tab and optionally setup an origin on the next selected tab.
0 commit comments