blazor communicate between components code example

Example 1: how to pass property between blazor components

public void ConfigureServices(IServiceCollection services)
{
    services.AddSingleton<Services.AppData>();
}

Example 2: how to pass property between blazor components

@page "/"
@inject Services.AppData AppData

<h1>First Page</h1>
<input type="number" @bind="AppData.Age" />
<br>
<a href="/page2">Go to Page 2</a>

Example 3: how to pass property between blazor components

@page "/page2"
@inject Services.AppData AppData

Tags:

Misc Example