Last active
May 8, 2020 22:28
-
-
Save gavilanch/f4ad9315f896c312a50020978cefbc89 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@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