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', () => {
100100 expect ( inputElement . indeterminate ) . toBe ( false ) ;
101101 } ) ;
102102
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+
103112 it ( 'should toggle checked state on click' , ( ) => {
104113 expect ( checkboxInstance . checked ) . toBe ( false ) ;
105114
Original file line number Diff line number Diff line change 11import {
2+ ChangeDetectorRef ,
23 ChangeDetectionStrategy ,
34 Component ,
45 ElementRef ,
@@ -156,7 +157,9 @@ export class MdCheckbox implements ControlValueAccessor {
156157
157158 hasFocus : boolean = false ;
158159
159- constructor ( private _renderer : Renderer , private _elementRef : ElementRef ) {
160+ constructor ( private _renderer : Renderer ,
161+ private _elementRef : ElementRef ,
162+ private _changeDetectorRef : ChangeDetectorRef ) {
160163 this . color = 'accent' ;
161164 }
162165
@@ -174,6 +177,7 @@ export class MdCheckbox implements ControlValueAccessor {
174177 this . _checked = checked ;
175178 this . _transitionCheckState (
176179 this . _checked ? TransitionCheckState . Checked : TransitionCheckState . Unchecked ) ;
180+ this . _changeDetectorRef . markForCheck ( ) ;
177181 }
178182 }
179183
You can’t perform that action at this time.
0 commit comments