...
 
Commits (2)
<label class="m-formInput__checkbox" [for]="id">
<input type="checkbox" [(ngModel)]="value" [id]="id" />
<input
type="checkbox"
[ngModel]="value"
(ngModelChange)="updateValue($event)"
[id]="id"
/>
<span class="m-formInputCheckbox__custom"></span>
<ng-content></ng-content>
</label>
......@@ -21,13 +21,17 @@ export const FORM_INPUT_CHECKBOX_VALUE_ACCESSOR: any = {
templateUrl: 'checkbox.component.html',
providers: [FORM_INPUT_CHECKBOX_VALUE_ACCESSOR],
})
export class FormInputCheckboxComponent
implements ControlValueAccessor, OnChanges {
export class FormInputCheckboxComponent implements ControlValueAccessor {
readonly id: string;
value: boolean = false;
@ViewChild('input', { static: true }) input: ElementRef;
updateValue(value: boolean) {
this.value = value;
this.propagateChange(this.value);
}
propagateChange = (_: any) => {};
constructor(private fb: FormBuilder) {
......@@ -38,10 +42,6 @@ export class FormInputCheckboxComponent
.substring(2); // Confirm duplicates not possible?
}
ngOnChanges(changes: any) {
this.propagateChange(changes);
}
writeValue(value: any): void {
this.value = value;
}
......