@page "/"
<MatSelect
Outlined="true"
Label="Category"
ValueChanged="(string i)=>OnChangeCategory(i)">
<MatOptionString></MatOptionString>
@foreach (var cat in GetCategories())
{
<MatOptionString Value="@cat">@cat</MatOptionString>
}
</MatSelect>
<MatSelect
Outlined="true"
Label="Product"
@bind-Value="@Product" >
<MatOptionString></MatOptionString>
@foreach (var prod in GetProducts(Category))
{
<MatOptionString Value="@prod">@prod</MatOptionString>
}
</MatSelect>
@code
{
protected string Category {set; get;} = "";
protected string Product {set; get;} = "";
protected async Task OnChangeCategory(string newValue)
{
this.Category = newValue;
// call background tasks
await Task.CompletedTask;
}
protected IEnumerable<string> GetCategories()
{
return new List<string>() { "one", "two", "three" };
}
protected IEnumerable<string> GetProducts(string category)
{
return (new List<string>() { "one", "two", "three" }).Select(x=>$"{category}-{x}" );
}
}