Basically I have two arrays, and I would like to store their values at the same time using a *ngFor, I did something like this just to show what I would expect:
I believe your mistake is having 2 arrays of controls instead of one array of groups:
alternativeFieldsAndValues: this.fbuilder.array([]),
and then:
get alternativeFieldsAndValues() {
return this.form.get('alternativeFieldsAndValues') as FormArray;
}
addAlternativeFieldAndValue() {
this.alternativeFieldsAndValues.push(this.fbuilder.group({
titulo: '',
conteudo: ''
}));
}
removeAlternativeFieldAndValue(index: any) {
this.alternativeFieldsAndValues.removeAt(index);
}
make sure to refactor all names properly then do this:
Titulo
Conteúdo
that being said, you could accomplish exactly what you asked like this:
Titulo
Conteúdo
but this does require the two lists are ALWAYS of the same length.