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

232
Visualizações
Assign custom values to ID and FOR properties of the checkbox and label resulted from ngFor loop to populate list

My problem is two-fold:

  1. I need to assign to each checkbox and label for checkbox unique ID and FOR value so each label corresponds to its according checkbox.
  2. Finally I need to capture which fields have been checked (I'm thinking somehow in a map, key being the country and value true/false) and create an SQL query which I can then send to the backend to retrieve the filtered result.

enter image description here

enter image description here

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

0

Something like this ?

<ng-container *ngFor="let country of countries$ | async">
  <input type="checkbox" [value]="country" id="cb-{{ country }}">
  <label for="cb-{{ country }}">{{ country }}</label>
</ng-container>
  countries$ = this.powerPlantService.getPowerPlantCountryNames().pipe(shareReplay(1));
about 4 years ago · Juan Pablo Isaza Relatório

0

Here is the answer for unique ID and FOR value. enter image description here

And here is how I capture the checked items and use them in a query: enter image description here

What I did was capture the check/uncheck and the name of the country in the countryNameAndCheckBoxStatus method inside the HTML component. Process these in an array inside the angular component and return the array so it can be processed further down the road into an sql query.

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