Skip to content

Instantly share code, notes, and snippets.

@gavilanch

gavilanch/Counter.razor

Last active May 8, 2020
Embed
What would you like to do?
@page "/counter"
@inject IJSRuntime js
<h1>Counter</h1>
<p>Current count: @currentCount</p>
<button id="counterClick" class="btn btn-primary" @onclick="IncrementCount">Click me</button>
@code {
private int currentCount = 0;
protected async override Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await js.InvokeVoidAsync("initializeCounterComponent");
}
}
private void IncrementCount()
{
currentCount++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.