Created
August 25, 2023 02:53
-
-
Save scottsauber/925d842071ea73a6a2466e601b22a6fb to your computer and use it in GitHub Desktop.
Data bind child to parent's data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In our child component | |
<input value="@Value" oninput="@OnValueChanged" /> | |
@code { | |
[Parameter] | |
public decimal Value { get; set; } | |
[Parameter] | |
public EventCallback<decimal> ValueChanged { get; set; } | |
private Task OnValueChanged(ChangeEventArgs e) | |
{ | |
Value = Convert.ToDecimal(e.Value ?? 0); | |
return ValueChanged.InvokeAsync(Value); | |
} | |
} | |
// In our parent component | |
<ChildComponent @bind-Value="transaction.SomePropertyName" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment