In order to use mat-autocomplete on any form control we need to fetch the valueChanges event to that particular form control. My formcontrol is present inside a formGroup which again uses formArray as shown below. I need valueChanges event for 'name' formcontrol which is fetched from addUserInfoFormGroup method.
I am using (this.myForm.get('usersInfo') as FormArray).controls[0].controls.name.valueChanges to fetch the valueChanges event, but it doesn't work.
my ts file
ngOnInit() {
this.myForm= new FormGroup({
usersInfo: this.fb.array([this.addUserInfoFormGroup()])
});
}
addUserInfoFormGroup() : FormGroup{
let userInfo = {
'name': ['',Validators.required],
'age': ['',Validators.required],
'role': ['',Validators.required],
};
return this.fb.group(userInfo );
}