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

161
Visualizações
Build Dynamic FormBuilder in Angular

I have created an Angular project with Dynamic Inputs, I click on a button then new inputs create and I want to use FormBuilder to get the data but I don't know how to do this.

I know how to use FormBuilder in the static case but I didn't find any resource for dynamic.

Which are the steps to follow to achieve that?

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

How are you adding new inputs to the existing formgroup? For example you can do this by using form arrays, and basically with that you are able to gate de value from it just by accessing like: formGroup.get("formArray").value -> you will get all the inputs value by one shot.

about 4 years ago · Juan Pablo Isaza Relatório

0

Im not too sure if this is what you meant but if you wanted to add new inputs everytime user clicks button and get the value then you could try this. expanding on @ZsoltB answer working stackblitz link

@Component({
  ...all the decorator things
})
export class AppComponent {
  formArray = new FormArray([
    new FormGroup({
      firstName: new FormControl(''),
      lastName: new FormControl(''),
    }),
  ]);
  name = 'angular';

  addNewInput = () => {
    this.formArray.push(
      new FormGroup({
        firstName: new FormControl(''),
        lastName: new FormControl(''),
      })
    );
  };
}
about 4 years ago · Juan Pablo Isaza Relatório

0

I solved the problem by using and inspired by the following code :

dynamic form in angular, add fields on runtime

thank you very much

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