Viewing the Expenses

Learn how to fetch expenses from the database and display them on the “Home” page.

We'll cover the following...

We need to add a table to display the list of expenses. We do this as follows:

  1. Return to Visual Studio.

  2. Open the ExpenseTracker.Client.Pages\Index.razor page.

  3. Update the markup to the following:

Press + to interact
@page "/"
@using ExpenseTracker.Shared
@inject HttpClient Http
<h2>Expenses</h2>
@if (expenses == null)
{
<p><em>Loading...</em></p>
}
else if (expenses.Count == 0)
{
<div>None Found</div>
}
else
{
}
@code{
IList<Expense> expenses;
}
...