How do I fill a MatSelect component at runtime

64 Views Asked by At
  1. I want to enable selecting values in a MatSelect component
  2. The MatSelect should contain a list of Objects from Tax, obtained after sending a Get Request to the API
  3. The Tax Object contains an Id and Percentage variables

The Problem is how do I populate MatSelect, below is the code I tried

I couldn't find examples

<MatSelect Label="Tax" @bind-Value="ProductData.TaxId">
    @foreach (var item in taxItems)
    {
        <MatOption Value="@item.Id">@item.Percentage</MatOption>
    }
</MatSelect>

public class Tax
{
    public int Id { get; set; }
    public double Percentage { get; set; }
}
0

There are 0 best solutions below