I use a <mat-checkbox>
and I bind its checked
attr to a inequality test. I also catch the change
event and so, it is possible to try to check the checkbox but the change handler rejects it.
HTML
<mat-checkbox [checked]="list.private === false" (change)="changeListVisibility(list)"></mat-checkbox>
TS
changeListVisibility(list) {
if(/* some test */) {
return; // do not accept the change
} else {
list.private = !list.private;
}
}
The problem is that, even if the change
handler rejects the change, the checkbox aspect will be like it has been accepted... (eg. the checkbox is unchecked -> the user clicks -> the change is rejected -> the checkbox will be checked).
Aucun commentaire:
Enregistrer un commentaire