Hi i try to create a search function, showing my data via blazor components.
The search function works fine, and return the result i want. But it does not update the old component. So if my search return 1 result, then the component only update the title, but other data from my model, will stay from the first loaded card. If search for an extra letter so item not exist, all the component will disapeer. But when i delete the last again, the component will show up again, with the right data.
<input type="search" @bind-value="SearchValue" @bind-value:event="oninput">
<div class="row justify-content-center mb-5">
@foreach (var item in FoundItems)
{
<ItemCard ItemDTO=item />
}
</div>
@code
public string SearchValue { get; set; } = "";
private List<ItemDTO> Items { get; set; }
protected async override Task OnInitializedAsync()
{Items = await _http.GetFromJsonAsync<List<ItemDTO>>("api/item");}
{
List<ItemDTO> FoundItems => Items.Where(i =>
i.Description.ToLower().Contains(SearchValue.ToLower())).ToList();
}