Angular2 手动触发 form.valueChanges
Angular2 Trigger form.valueChanges manually
我正在订阅我的表单更改:
this.form.valueChanges.subscribe(formData => { // Data is saved here. });
当我单击表单中的按钮时,它会更改其中一个输入值。不知何故 valueChanges 订阅没有被触发。我可以手动执行此操作吗?
我相信您需要在订阅之前映射值更改,例如:
this.physicalForm.valueChanges
.map((value) => {
return value;
})
.subscribe((value) => {
this.selectedPhysical.activityLevel = this.physicalForm.value.activityLevel;
});
我正在订阅我的表单更改:
this.form.valueChanges.subscribe(formData => { // Data is saved here. });
当我单击表单中的按钮时,它会更改其中一个输入值。不知何故 valueChanges 订阅没有被触发。我可以手动执行此操作吗?
我相信您需要在订阅之前映射值更改,例如:
this.physicalForm.valueChanges
.map((value) => {
return value;
})
.subscribe((value) => {
this.selectedPhysical.activityLevel = this.physicalForm.value.activityLevel;
});