默认情况下,需要选中/选中复选框值。尝试了以下不起作用的方法。
html
<form [formGroup]="form">
<label><input type="checkbox" class="form-check-input" [(ngModel)]="organism.active" formControlName="active" >Selected</label>
</form>
ts
constructor() { this.getFromGroup(); }
private getFromGroup() {
this.form = this.formBuilder.group({
'active': new FormControl(true),
})
}
甚至尝试过此
this.form.patchValue({
'active': true
})
只需将属性添加到输入checked="checked"
,它将起作用