I have a problem getting an id from my form.
this.myForm looks like this @Input() public myForm: FormGroup;
it is a input from another .ts file
this is the structure of the form:
myForm
- firstname
- lastname
- Email
--Tags (FormArray)
---id (FormGroup)
I want to get access to the id and fill this.selectedTagList with all the tags from one user and this is what i'm trying to do:
const control: FormArray = <FormArray>this.myForm.controls[ 'tags' ];
control.controls.forEach(tag=> {
this.selectedTagList.push(this.tagList.find(tag.value.id));
});
if i console.log(this.myForm) i get this structure:
console.log(control.controls), 'controls' from the code above:
but when i do console.log(control.controls.length) i get 0. Or when i do console.log(control.controls[0]) i get undefined.
I have no idea where the FormGroup objects went or why it says Array[0] with 4 FormGroup objects in it.