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

139
Visualizações
How to populate the option items from the service

I have an angular application In this I haveto populate the dropdown lsts from the backend.

.component.ts

public getMemberCodes() {
    let baseUrl = `/endpoindAPI`;
    this._restfulService
      .restfulGetData(baseUrl)
      .subscribe(
        (actionLookupData: ActionLookupData) => {
          if (actionLookupData) {
            this.option1Codes = actionLookupData.Option1Codes;
               this.option2Codes = actionLookupData.Option2Codes;
               this.option3Codes = actionLookupData.Option3Codes;
          
 }
        },
        (err) => {
          console.error(err);
        }
      );
  }

From the above service I have to populate the values of Categories from each one like this.option1Codes,this.option1Codes..etc

the response is like below:

Option1Codes: [{Category: "Category1", ActionStatusTypeID: 1,Complete", ActionID: 5060,…}] Option2Codes: [{Category: "Category2", ActionStatusTypeID: 1,Complete", ActionID: 5060,…}]

From the above array I have to populate only Category values in dropdown lists from the backend.

.component.html

 <select    class="form-control"  required>
<option>
//code 
</option>
</select>
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can use the ngFor directive:

<select *ngFor="let optionCode of OptionCodes"> {{ link }}

I would recommend you have a look at the official documentation on the matter

about 4 years ago · Juan Pablo Isaza Relatório

0

If you have Only on List

Option1Codes: [{Category: "Category1", ActionStatusTypeID: 1,Complete", ActionID: 5060,…}]

Use this Way

<select  *ngFor="let optionCode of Option1Codes"  class="form-control"  required>
<option>
{{optionCode?.Category}}
</option>
</select>

As I see You have three List option1Codes,option2Codes,option3Codes.

If you want It in one list then you have to add all list in one Array Like this...

 let list = [...option1,...option2,...option3];

<select  *ngFor="let optionCode of list"  class="form-control"  required>
    <option>
    {{optionCode?.Category}}
    </option>
    </select>
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