Angular 将FormGroup中的控件配置为不返回值
在定义FormGroup实例时,是否可以在使用Angular 将FormGroup中的控件配置为不返回值,angular,typescript,Angular,Typescript,在定义FormGroup实例时,是否可以在使用.getRawValues或任何其他属性时将某些属性设置为不返回值 我知道禁用的控件在使用.value时不会返回,但我需要将其他控件设置为不返回值 以下是FormGroup的定义: this.form = this.formBuilder.group( { id: [null], prop1: [null, Validators.required], prop2: [null, Validators.required], prop3:
.getRawValues
或任何其他属性时将某些属性设置为不返回值
我知道禁用的控件在使用.value
时不会返回,但我需要将其他控件设置为不返回值
以下是FormGroup的定义:
this.form = this.formBuilder.group(
{
id: [null],
prop1: [null, Validators.required],
prop2: [null, Validators.required],
prop3: [null, ... something like Ignore..]
});
因此,在使用时:
this.form.getRawValue()
我得到:
{id, prop1, prop2}
您可以复制表单值并删除不需要的属性
let {prop2, ...valuesYouWant} = yourFormValues