1

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.

thanks

Jonathan
  • 4,724
  • 7
  • 45
  • 65

1 Answers1

2

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.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
Jonathan
  • 4,724
  • 7
  • 45
  • 65