form control inside ngIf is still invalidating the whole form


I have a input component that uses a Control for validation.
This component is being used within a label that has a ngIf attached.
When the ngIf is false, the input is not being rendered, thats expected and ok, but the problem is that it stills invalidates the whole form.

What could I do to so that the form is not invalidated by an input that is inside a false ngIf statement.



Found the answer.
I didn’t know that the ngIf destroys the components inside it when it gets a false expression result.
My component dynamically creates a validity Control and attach it to the ControlGroup of a Submitter component on ngInit.
Now I need to detach it from the controlgroup on ngDestroy.

Answered By – Jonathan

Answer Checked By – Terry (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *