您好,我使用反应式表单将对象数组绑定到 formArray,但在这里,如果我选择一个部分中的任何一项,然后单击“向右移动/向左移动”,则整个对象已从一个部分移动到另一部分。但该功能工作正常,但我无法检测到 form.valuechanges() 中从一个部分到其他部分所做的更改。任何人都可以帮助我检测更改,以防项目已从一个部分移动到另一部分,在这里我想要更改检测,但功能必须按原样工作,我的意思是整个对象从一个部分移动到另一部分。
提前致谢。
我这里有工作 demo2,我希望我之前发布的 demo1 能够像这个 demo2 一样工作,并且 formarray 工作。 演示2
演示: 演示 1
TS:
private settingsGroupInfoForm() {
if (!this.agentDetailsList) {
// Add
this.agentGroupViewInfoForm = this.FB.group({
agentGroupView: this.FB.array(
this.agentInView.map(x=>(x))
),
})
} else {
// Edit
if (this.agentDetailsList) {
this.agentGroupViewInfoForm = this.FB.group({
agentGroupView: this.FB.array(this.agentInView.map(x=>(x))),
})
}
this.agentGroupViewInfoForm.valueChanges.subscribe(data => {
this.formEdit = true;
console.log('agentGroupViewInfoForm', this.formEdit)
})
}
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<div class="card-body overflow-auto py-0" *ngIf="agentGroupViewInfoForm"
[formGroup]="agentGroupViewInfoForm">
<ul class="list-group list-group-flush" *ngFor="let child of agentInView" name="agentInGroup" formArrayName="agentGroupView">
<li class="list-group-item {{isInActiveItems(child) ? …Run Code Online (Sandbox Code Playgroud)