简体   繁体   English

如何获得角形的无功形式值分量?

[英]How get reactive form value component in angular?

How to access the value of each of the iterated forms of the child component ?. 如何访问子组件的每种迭代形式的值? The parent component has a button which must generate an array of child forms, but must go through all those forms. 父组件具有一个按钮,该按钮必须生成一系列子表单,但必须遍历所有这些表单。 Can it be with a viewChid? 可以使用viewChid吗?

HTML HTML

<form novalidate
  [formGroup]="fatherForm">
    <div *ngFor="let item of items>
      <children-form
        [item]="item">
      </children-form>
    </div>
</form>

TS TS

<button (click)="save()">Save</button>

Maybe you can use @ViewChildren , here is a demo. 也许您可以使用@ViewChildren ,这是一个演示。

@ViewChildren(ChildrenFromComponent)
childrenFormCmps: QueryList<ChildrenFromComponent>;

ngAfterViewInit() {
    console.dir(this.childrenFormCmps);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM