File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,15 @@ describe('MdCheckbox', () => {
100
100
expect ( inputElement . indeterminate ) . toBe ( false ) ;
101
101
} ) ;
102
102
103
+ it ( 'should change native element checked when check programmatically' , ( ) => {
104
+ expect ( inputElement . checked ) . toBe ( false ) ;
105
+
106
+ checkboxInstance . checked = true ;
107
+ fixture . detectChanges ( ) ;
108
+
109
+ expect ( inputElement . checked ) . toBe ( true ) ;
110
+ } ) ;
111
+
103
112
it ( 'should toggle checked state on click' , ( ) => {
104
113
expect ( checkboxInstance . checked ) . toBe ( false ) ;
105
114
Original file line number Diff line number Diff line change 1
1
import {
2
+ ChangeDetectorRef ,
2
3
ChangeDetectionStrategy ,
3
4
Component ,
4
5
ElementRef ,
@@ -156,7 +157,9 @@ export class MdCheckbox implements ControlValueAccessor {
156
157
157
158
hasFocus : boolean = false ;
158
159
159
- constructor ( private _renderer : Renderer , private _elementRef : ElementRef ) {
160
+ constructor ( private _renderer : Renderer ,
161
+ private _elementRef : ElementRef ,
162
+ private _changeDetectorRef : ChangeDetectorRef ) {
160
163
this . color = 'accent' ;
161
164
}
162
165
@@ -174,6 +177,7 @@ export class MdCheckbox implements ControlValueAccessor {
174
177
this . _checked = checked ;
175
178
this . _transitionCheckState (
176
179
this . _checked ? TransitionCheckState . Checked : TransitionCheckState . Unchecked ) ;
180
+ this . _changeDetectorRef . markForCheck ( ) ;
177
181
}
178
182
}
179
183
You can’t perform that action at this time.
0 commit comments