[英]Angular2 Trigger form.valueChanges manually
I'm subscribing to my form changes with: 我正在通过以下方式订阅我的表单更改:
this.form.valueChanges.subscribe(formData => { // Data is saved here. });
When I click a button in my form it changes one of the input values. 当我单击表单中的按钮时,它将更改输入值之一。 Somehow the valueChanges subscribe is not being triggered. 以某种方式未触发valueChanges订阅。 Can I do this manually? 我可以手动做吗?
I believe you need to map the valuechanges before subscribing like: 我相信您需要在订阅以下内容之前先映射值更改:
this.physicalForm.valueChanges
.map((value) => {
return value;
})
.subscribe((value) => {
this.selectedPhysical.activityLevel = this.physicalForm.value.activityLevel;
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.