1

In Angular ReactiveForm examples, I saw the following code snippet:

<form novalidate [formGroup]="myGroup">
   Name: <input type="text" formControlName="name">
   Location: <input type="text" formControlName="location">
</form>

Where myGroup is defined as:

ngOnInit() {
   this.myGroup = new FormGroup({
       name: new FormControl('Todd Motto'),
       location: new FormControl('England, UK')
   });
}

For the property binding [formGroup]="myGroup", the data flows from the model (myGroup) to the view. So when the user change the input, how is the change reflected back in the model?

1 Answer 1

1
console.log(this.myGroup.value);

returns an object with "input name properties" and model values, besides there is onValueChange observable. So you can subscribe to it.

Sign up to request clarification or add additional context in comments.

1 Comment

My question was who changes myGroup? In the property binding [formGroup]="myGroup", the changes "flow" from myGroup to fromGroup, is not it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.