【发布时间】:2018-11-04 07:50:26
【问题描述】:
当我在另一个 formBuilder 组中有一个数组时,我想知道如何以反应形式使用“setControl”和“get”。例如:
this.formulario = this.formBuilder.group({
title: [this.racPessoa.title, [Validators.required]],
description: [this.racPessoa.description, [Validators.required]],
person: this.formBuilder.group({
idPerson:[this.racPessoa.person.idPerson],
name:[this.racPessoa.person.nome],
personDocument: this.formBuilder.array([])
}),
});
在上面的情况下,如果我想处理“标题,我可以写:
this.formulario.setControl('title', something);
this.formulario.get('title');
但是当我想处理一个人内部的“personDocument”时,我不知道如何写上面的两个句子
我试过用:
this.formulario.setControl('person.personDocument', something);
this.formulario.get('person.personDocument')
但它不起作用。
【问题讨论】:
-
有什么理由要使用 setControl?
-
我正在使用 setcontrol 和 getcontrol 来添加/删除该数组的字段
标签: angular angular2-forms angular-reactive-forms angular2-formbuilder