Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

103
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda