Created
May 29, 2019 03:23
-
-
Save danielplawgo/9a8b79fb6e2131eca8d12725f44be8c2 to your computer and use it in GitHub Desktop.
Blazor geek just join it
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" | |
<h1>Counter</h1> | |
<p>Current count: @currentCount</p> | |
<button class="btn btn-primary" onclick="@IncrementCount">Click me</button> | |
@functions { | |
int currentCount = 0; | |
void IncrementCount() | |
{ | |
currentCount++; | |
} | |
} |
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 "/fetchdata" | |
@inject HttpClient Http | |
<h1>Weather forecast</h1> | |
<p>This component demonstrates fetching data from the server.</p> | |
@if (forecasts == null) | |
{ | |
<p><em>Loading...</em></p> | |
} | |
else | |
{ | |
<table class="table"> | |
<thead> | |
<tr> | |
<th>Date</th> | |
<th>Temp. (C)</th> | |
<th>Temp. (F)</th> | |
<th>Summary</th> | |
</tr> | |
</thead> | |
<tbody> | |
@foreach (var forecast in forecasts) | |
{ | |
<tr> | |
<td>@forecast.Date.ToShortDateString()</td> | |
<td>@forecast.TemperatureC</td> | |
<td>@forecast.TemperatureF</td> | |
<td>@forecast.Summary</td> | |
</tr> | |
} | |
</tbody> | |
</table> | |
} | |
@functions { | |
WeatherForecast[] forecasts; | |
protected override async Task OnInitAsync() | |
{ | |
forecasts = await Http.GetJsonAsync<WeatherForecast[]>("sample-data/weather.json"); | |
} | |
class WeatherForecast | |
{ | |
public DateTime Date { get; set; } | |
public int TemperatureC { get; set; } | |
public int TemperatureF { get; set; } | |
public string Summary { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment