Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

138
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!