Angular 2Angular 2 Data Driven Forms

Remarks

this.myForm = this.formBuilder.group

creates a form object with user's configuration and assigns it to this.myForm variable.

'loginCredentials': this.formBuilder.group

method creates a group of controls which consist of a formControlName eg. login and value ['', Validators.required], where the first parameter is the initial value of the form input and the secons is a validator or an array of validators as in 'email': ['', [Validators.required, customValidator]],.

'hobbies': this.formBuilder.array

Creates an array of groups where the index of the group is formGroupName in the array and is accessed like :