File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed
Getting-started/Blazor/Blazor-WASM-app/Create-PowerPoint-presentation/Pages Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change 1+ @page " /fetchdata"
2+ @inject HttpClient Http
3+
4+ <h1 >Weather forecast</h1 >
5+
6+ <p >This component demonstrates fetching data from the server.</p >
7+
8+ @if (forecasts == null )
9+ {
10+ <p ><em >Loading .. .</em ></p >
11+ }
12+ else
13+ {
14+ <table class =" table" >
15+ <thead >
16+ <tr >
17+ <th >Date </th >
18+ <th >Temp . (C )</th >
19+ <th >Temp . (F )</th >
20+ <th >Summary </th >
21+ </tr >
22+ </thead >
23+ <tbody >
24+ @foreach ( var forecast in forecasts )
25+ {
26+ <tr >
27+ <td >@forecast.Date.ToShortDateString() </td >
28+ <td >@forecast.TemperatureC </td >
29+ <td >@forecast.TemperatureF </td >
30+ <td >@forecast.Summary </td >
31+ </tr >
32+ }
33+ </tbody >
34+ </table >
35+ }
36+
37+ @code {
38+ private WeatherForecast [] forecasts ;
39+
40+ protected override async Task OnInitializedAsync ()
41+ {
42+ forecasts = await Http .GetFromJsonAsync <WeatherForecast []>(" sample-data/weather.json" );
43+ }
44+
45+ public class WeatherForecast
46+ {
47+ public DateTime Date { get ; set ; }
48+
49+ public int TemperatureC { get ; set ; }
50+
51+ public string Summary { get ; set ; }
52+
53+ public int TemperatureF => 32 + (int )(TemperatureC / 0 . 5556 );
54+ }
55+ }
You can’t perform that action at this time.
0 commit comments