44 Input ,
55 Output ,
66 EventEmitter ,
7+ ChangeDetectorRef ,
78 ViewChild
89} from '@angular/core' ;
910import {
@@ -77,20 +78,17 @@ export class SamCheckboxComponent implements ControlValueAccessor {
7778 */
7879 @Input ( ) id : string ;
7980
80- public optionChange :string ;
81+ public optionChange : string ;
8182
82- public optionId :string ;
83-
84-
85-
83+ public optionId : string ;
8684 /**
8785 * Deprecated, Event emitted when the model value changes
8886 */
8987 @Output ( ) modelChange : EventEmitter < any > = new EventEmitter < any > ( ) ;
9088
9189 @Output ( ) optionSelected : EventEmitter < any > = new EventEmitter < any > ( ) ;
9290
93- @ViewChild ( FieldsetWrapper , { static : true } )
91+ @ViewChild ( FieldsetWrapper , { static : true } )
9492 public wrapper : FieldsetWrapper ;
9593 activeOptions = 0 ;
9694 /*
@@ -103,7 +101,7 @@ export class SamCheckboxComponent implements ControlValueAccessor {
103101 onChange : any = ( c ) => undefined ;
104102
105103 onTouched : any = ( ) => undefined ;
106-
104+
107105 get value ( ) {
108106 return this . model ;
109107 }
@@ -114,7 +112,7 @@ export class SamCheckboxComponent implements ControlValueAccessor {
114112 this . onTouched ( ) ;
115113 }
116114
117- constructor ( protected samFormService : SamFormService ) { }
115+ constructor ( protected samFormService : SamFormService , private cdr : ChangeDetectorRef ) { }
118116
119117 ngOnInit ( ) {
120118 // initialize the order lookup map
@@ -148,17 +146,18 @@ export class SamCheckboxComponent implements ControlValueAccessor {
148146 }
149147 }
150148 this . model = returnVal ;
149+ this . cdr . detectChanges ( ) ;
151150 this . setSelectAllCheck ( ) ;
152151 }
153152
154- setSelectAllCheck ( ) {
153+ setSelectAllCheck ( ) {
155154 let activeOptionsNum = 0 ;
156- this . options . forEach ( val => {
157- if ( ! val . disabled ) {
155+ this . options . forEach ( val => {
156+ if ( ! val . disabled ) {
158157 activeOptionsNum ++ ;
159158 }
160159 } ) ;
161- this . activeOptions = activeOptionsNum ;
160+ this . activeOptions = activeOptionsNum ;
162161 }
163162
164163 // Give the check all label a name for screen readers
@@ -216,8 +215,8 @@ export class SamCheckboxComponent implements ControlValueAccessor {
216215 emitModel ( ) {
217216
218217 this . modelChange . emit ( this . model ) ;
219-
220- this . optionSelected . emit ( { model : this . model , selected : this . optionChange , id : this . optionId } ) ;
218+
219+ this . optionSelected . emit ( { model : this . model , selected : this . optionChange , id : this . optionId } ) ;
221220 }
222221
223222 registerOnChange ( fn ) {
0 commit comments