0

On a AbstractControl, there is an observable property valueChanges. This will fire when a new control is added to the FormGroup but it also fires when a single control value is edited. I only want to be notified when a control is added so I can call patchValue(state); Or if there is a way to only patch the values that aren't dirty would work as well.

Jacob Roberts
  • 1,725
  • 3
  • 16
  • 24
  • 1
    what is the exact requirement ? – Rahul Singh Sep 02 '17 at 18:01
  • Simultaneous updates to state by varying users... Example; during the edit process, if someone else makes changes to the editing state, the user will be notified that the value has changed so they can choose to accept or ignore. – Jacob Roberts Sep 02 '17 at 18:53
  • everytime a control is added you will add it via a method you can get the notification there. Or you want to check if a form control becomes dirty and then trigger update? – Rahul Singh Sep 02 '17 at 18:57
  • Where does it say valueChanges fires when control is added to FormGroup? – JGFMK Sep 02 '17 at 19:02
  • https://angular.io/api/forms/AbstractControl has booleans for pristine, dirty, touched and untouched – JGFMK Sep 02 '17 at 19:06
  • @JGFMK check this plunker https://plnkr.co/edit/v7USKj8elVn6wHxKPGe5?p=preview – Jacob Roberts Sep 02 '17 at 19:08
  • hmmm... I guess I could iterate controls of the form group and call patch on them individually if they aren't dirty. Can also send a notification at that time if it is dirty. – Jacob Roberts Sep 02 '17 at 19:10
  • https://stackoverflow.com/questions/42235156/angular-2-iterate-over-reactive-form-controls – JGFMK Sep 02 '17 at 19:11
  • Thanks guys... guess I just needed someone to talk to ;) – Jacob Roberts Sep 02 '17 at 19:11

0 Answers0