角动态表单会更改一个子组件值,而另一个子组件值也已更改

问题描述

我已经实现了一个动态的角度表单应用程序,该应用程序也使用了子组件,现在我遇到了一个问题,如果我更改了值,例如子组件中的输入字段,以及动态创建的其他输入字段也从这个子组件也更改了。

现在我显示您的代码

父组件

 <div
              *ngFor="let contact of form.get('contacts').controls; let contactIndex = index">
              <div [formGroupName]="contactIndex">
<div fxLayout="row" class="parameterWrapper">
                  <div class="parameterLabel step">contact</div>
                  <modification-dropdown
                  [group]="contact"
                  name="cType"
                  [enumValues]="enumValues"
                  ></modification-dropdown>
                </div>

和子组件

<label [formGroup]="group">
  <div fxLayout="row">
    <select class="parameterInputSelect" [formControlName]="name">
      <option *ngFor="let value of enumValues" [value]="value">
        {{value}}</option>
    </select>
  </div>
</label>

和子组件ts文件

export class ModificationDropdownComponent{
  @input() group: FormGroup;
  @input() enumValues: string[];
  @input() name: string;

  constructor() {
  }
}

问题是,如果我更改了一个下拉框,而另一个下拉框也发生了更改。

任何解决方案?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)