问题描述
当用户选中一个复选框时,我想patchValue并选择其父级。 在onSelectionChange函数中,即使我仅指定修补其父项的值,也已选中了所有复选框。
您知道如何以编程方式仅选择其父项-event.target.value而不是全部复选框吗?
`
constructor(private fb: FormBuilder,public intl: SharedIntl) {
super();
this.form = this.fb.group({
checkBoxFilterChoice: ''
});
}
<form class="form" [formGroup]="form" novalidate>
<div *ngFor="let item of items">
<clr-checkBox-container *ngIf="!!item?.checkBox">
<clr-checkBox-wrapper *ngFor="let option of item?.checkBox">
<input type="checkBox" clrCheckBox (change)="onSelectionChange($event)" value={{option?.parent.filterPillValue}} formControlName="checkBoxFilterChoice" name={{option.filterPillValue}} />
<label class="checkBox-label">{{option?.label}}</label>
</clr-checkBox-wrapper>
</clr-checkBox-container>
</div>
</form>
onSelectionChange(event) {
this.form.patchValue({
checkBoxFilterChoice: event.target.value
},{emitEvent: false});
}
}
`
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)