I have a formgroup name studentRegistrationForm. In this form i want to create
dynamically studentList array but i can not done this.
ngOnInit(){
this.studentRegistrationForm = this.formBuilder.group({
session: ['', [Validators.required]],
semester: ['', [Validators.required]],
students: ['',[Validators.required]],
studentList: this.formBuilder.array([
]),
});
let control = <FormArray>this.studentRegistrationForm.controls['studentList'];
this.studentRegistrationForm.valueChanges
.subscribe( data => {
if(data.semester && data.session && data.students){
control.push(this.createStudent());
}
});
}
createStudent() {
return new FormGroup({
id: new FormControl('', Validators.required),
email: new FormControl('',Validators.required)
})
}

studentListform control is in the form) every time a value in the form changes... which triggers another form change... etc.