0

I have a dropdown that I am trying to populate dynamically using the following data set

this.additionalPercentages = this.offer.offerData.wellbeing.retirementPackages[0].additionalVoluntaryContributionPercentages;

this.additionalPercentages is consoled and looking like this: [5, 6]

<p-dropdown
      (onChange) = "getAdditionalPercentage($event)"
      class="fund-dropdown"
      [options]="additionalPercentages"
      [showClear]="false"
></p-dropdown>

After doing this, I see that the dropdown is blank with no errors in the console either. Any ideas?

1 Answer 1

1

options takes

An array of objects to display as the available options.

So you need to change your additionalPercentages into array of objects i.e.

[
  {label: 5, value: 5},
  {label: 6, value: 6}
]

Code:

this.additionalPercentages=this.additionalPercentages.map(
      (item)=>({label:item,value:item}));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.