@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