Mike Mike - 10 months ago 184
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;