@@ -25,8 +25,6 @@ import {
25
25
ViewEncapsulation ,
26
26
} from '@angular/core' ;
27
27
import { coerceBooleanProperty } from '@angular/cdk/coercion' ;
28
- import { map } from '@angular/cdk/rxjs' ;
29
- import { Observable } from 'rxjs/Observable' ;
30
28
import { Subscription } from 'rxjs/Subscription' ;
31
29
import { MdTab } from './tab' ;
32
30
import { merge } from 'rxjs/observable/merge' ;
@@ -131,9 +129,7 @@ export class MdTabGroup extends _MdTabGroupMixinBase implements AfterContentInit
131
129
private _backgroundColor : ThemePalette ;
132
130
133
131
/** 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 ( ) ;
137
133
138
134
/** Event emitted when focus has changed within a tab group. */
139
135
@Output ( ) focusChange : EventEmitter < MdTabChangeEvent > = new EventEmitter < MdTabChangeEvent > ( ) ;
@@ -157,16 +153,20 @@ export class MdTabGroup extends _MdTabGroupMixinBase implements AfterContentInit
157
153
* a new selected tab should transition in (from the left or right).
158
154
*/
159
155
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).
163
160
let indexToSelect = this . _indexToSelect =
164
161
Math . min ( this . _tabs . length - 1 , Math . max ( this . _indexToSelect || 0 , 0 ) ) ;
165
162
166
163
// If there is a change in selected index, emit a change event. Should not trigger if
167
164
// the selected index has not yet been initialized.
168
165
if ( this . _selectedIndex != indexToSelect && this . _selectedIndex != null ) {
169
166
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 ) ) ;
170
170
}
171
171
172
172
// Setup the position for each tab and optionally setup an origin on the next selected tab.
0 commit comments