Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

143
Vistas
Creating dynamic inputs in NgForm with child components

Hello Stack Overflow Community I hope you are having a great day, today I have an issue that I have been trying to figure out and I hope you can tell me how it is done.

Story
I'm trying to create a form with dynamic fields, meaning the form doesn't have defined FormControls, Validators, or anything.
It only has the fields that are active on the form when the form is submitted.\

Ex.
<child-component *ngIf="condition" ngModel ngDefaultControl></child-component>
Is now active and is in the NgForm object and can be sent to the database.
or
Is now not active and is not in the NgForm object and can then not be sent to the database.

The rest of the active fields are then in the object but not the deactivated <child-component>.
I have gotten this to work, however, I'm trying to add " error handling" to the <child-component> to check if the field is empty if it is required and if it is of the type that it is supposed to be Ex. number, text, etc.
I have issues with getting the " error handling" to work.

Question
How do I add an error to my <child-component> if it is required and empty or if the value of the <child-component> input is not of the same type as the input?

Link to StackBlitz (doesn't open in a new window)

Thank you for taking the time to help me out.

Best regards,
Alexander

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda