Mike Mike - 1 year ago 253
TypeScript Question

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. Can I do this manually?

Answer Source

I believe you need to map the valuechanges before subscribing like:

       .map((value) => {
          return value;
       .subscribe((value) => {
         this.selectedPhysical.activityLevel = this.physicalForm.value.activityLevel;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download