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

136
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 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