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

104
Vistas
Angular dynamically add a fieldset with and input and button

I want to have a form, which has an input field taking numbers (15,30,45), which will be used as minutes. It is supposed to have an add button, which will add another row of that input with that add button beside it aswell. If I have more than one of those fieldsets, then I want to have a button besides all fieldsets, that can delete the input.

<div id="minute">
  <label for="MinuteImput">In Minute </label>
  <input type="number" id="MinuteImput" min="0" max="45" step="15">
  <button>+</button>
  <button *ngIf="count divs with id minute > 1" >-</button>
</div>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

In Angular framework try to avoid using "id" itself. The theme of this framework is data binding. For your case you need to use "ngFor". Something like following.

<div *ngFor='let num of inptFieldArray'>
  <label for="MinuteImput">In Minute </label>
  <input type="number" id="MinuteImput" min="0" max="45" step="15">
  <button (click)="inptFieldArray.push(inptFieldArray.length)">+</button>
  <button *ngIf="inptFieldArray.length> 1"  (click)="remove(num)">-</button>
</div>

Reference

about 4 years ago · Juan Pablo Isaza Denunciar
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