Angular2:在FormGroup.value

时间:2017-02-25 06:30:44

标签: angular

我有:

this.editMemberForm = this.formBuilder.group({
  name: [{value: '', disabled: true}],
  id: [{value: '', disabled: true}],
  relType: ''
});

然后我将值设置为禁用的表单控件:

this.editMemberForm.patchValue({
  name: 'Me',
  id: '000',
});

onSubmit()

console.log('Saving data', this.editMemberForm.value);
// { relType: '123' }

我需要this.editMemberForm.value{ name: "Me", id: '000', relType: "123" }

1 个答案:

答案 0 :(得分:2)

您也可以使用getRawValue()来恢复已禁用的控件值。