Skip to content

Commit c945ce2

Browse files
committed
feat(checkbox): add change detection
1 parent 3520581 commit c945ce2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

projects/components/src/checkbox/checkbox.component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
1+
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core';
22
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
33
import { MatCheckboxChange } from '@angular/material/checkbox';
44

@@ -49,6 +49,8 @@ export class CheckboxComponent implements ControlValueAccessor {
4949
private onTouched!: () => void;
5050
private onChanged!: (value: boolean) => void;
5151

52+
public constructor(private readonly cdr: ChangeDetectorRef) {}
53+
5254
public onCheckboxChange(event: MatCheckboxChange): void {
5355
this.isChecked = event.checked;
5456
this.checkedChange.emit(this.isChecked);
@@ -66,9 +68,11 @@ export class CheckboxComponent implements ControlValueAccessor {
6668

6769
public setDisabledState(isDisabled: boolean): void {
6870
this.isDisabled = isDisabled;
71+
this.cdr.markForCheck();
6972
}
7073

7174
public writeValue(isChecked: boolean | undefined): void {
7275
this.isChecked = isChecked ?? false;
76+
this.cdr.markForCheck();
7377
}
7478
}

0 commit comments

Comments
 (0)