当检查角材料mat-checkbox
(https://material.angular.io/components/checkbox/overview)时,它具有“ true”的值。未选中时,它的值为“false”。
有没有办法扭转这种行为?我需要的正好相反。选中的复选框应在调用时序列化为“false”,未选中的复选框应序列化为“true” this.filterFormGroup.getRawValue()
。
我希望有这样的事情:
<mat-checkbox [myCustomCheckedValue]="false" [myCustomUnCheckedValue]="true"></mat-checkbox>
或者我是否需要像这样创建一个自定义指令:
<mat-inverted-checkbox></mat-inverted-checkbox>
我的目标是这段代码:
this.filterGroup = new FormGroup({
resolved: new FormControl(),
});
this.filterGroup.getRawValue();
{resolved: false}
选中复选框时返回。