When a Angular Material mat-checkbox
(https://material.angular.io/components/checkbox/overview) is checked it has the value "true". When it is unchecked it has the value "false".
Is there a way to turn this behaviour around? I need just the opposite. A checked checkbox should serialize to "false" and a unchecked one should serialize to "true" when calling this.filterFormGroup.getRawValue()
.
I was hoping that there is something like this:
<mat-checkbox [myCustomCheckedValue]="false" [myCustomUnCheckedValue]="true"></mat-checkbox>
Or do I need to create a custom directive like so:
<mat-inverted-checkbox></mat-inverted-checkbox>
My goal is that this code:
this.filterGroup = new FormGroup({
resolved: new FormControl(),
});
this.filterGroup.getRawValue();
returns {resolved: false}
when the checkbox is checked.