1

I'm trying to make an Ionic 3 app with Angular 7. I have a dynamic reactive form where a new form group is being added when you click on a button.

How do I validate the nested fields? How do I write the getter or how to address the needed field in html?

The main problem is that I have an array of the FormGroups (see PostPieces) so from Angular the validator doesn't know which PostPiece from array it refers too so I don't really know how to write a getter for this. The form DOES get invalid BUT I can't output the message because I don't know how to the condition check in this case.

My html & angular: Angular HTML

3
  • A factory function. Create a function that takes in the validation rules as a parameter and then creates your new FormGroup, applying those rules to it. Such a function might live in a service. Also see angular.io/guide/form-validation for basic feedback for the user ideas. Commented Mar 8, 2019 at 15:57
  • Possible duplicate of Angular 6 Nested FormGroup Template Validation Commented Mar 8, 2019 at 15:57
  • @KeenanDiggs The problem is that angular doesn't know to which object from array to refer when checking if it's valid or no Commented Mar 8, 2019 at 16:07

1 Answer 1

0

I've found a solution!

It's writing a function which would get the needed FormGroup by index and then using it in the ngIf part as usually. Source

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.