blazor get value from another component code example
Example 1: how to pass property between blazor components
@page "/page2"
@inject Services.AppData AppData
Example 2: how to pass property between blazor components
using System;
namespace AppDataService.Services
{
public class AppData
{
private int _number;
public int Number
{
get
{
return _number;
}
set
{
_number = value;
NotifyDataChanged();
}
}
private string _color;
public string Color
{
get
{
return _color;
}
set
{
_color = value;
NotifyDataChanged();
}
}
public event Action OnChange;
private void NotifyDataChanged() => OnChange?.Invoke();
}
}