mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-24 02:30:13 +00:00
Add AureliaSpa template (#398)
This commit is contained in:
committed by
SteveSandersonMS
parent
867e60d7fd
commit
e60ea04f86
@@ -0,0 +1,26 @@
|
||||
<template>
|
||||
<h1>Weather forecast</h1>
|
||||
|
||||
<p>This component demonstrates fetching data from the server.</p>
|
||||
|
||||
<p if.bind="!forecasts"><em>Loading...</em></p>
|
||||
|
||||
<table if.bind="forecasts" class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Temp. (C)</th>
|
||||
<th>Temp. (F)</th>
|
||||
<th>Summary</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr repeat.for="forecast of forecasts">
|
||||
<td>${ forecast.dateFormatted }</td>
|
||||
<td>${ forecast.temperatureC }</td>
|
||||
<td>${ forecast.temperatureF }</td>
|
||||
<td>${ forecast.summary }</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</template>
|
||||
@@ -0,0 +1,24 @@
|
||||
/// <reference path="../../../../node_modules/aurelia-fetch-client/doc/whatwg-fetch.d.ts" />
|
||||
/// <reference path="../../../../node_modules/aurelia-fetch-client/doc/url.d.ts" />
|
||||
import { HttpClient } from 'aurelia-fetch-client';
|
||||
import { inject } from 'aurelia-framework';
|
||||
|
||||
@inject(HttpClient)
|
||||
export class Fetchdata {
|
||||
public forecasts: WeatherForecast[];
|
||||
|
||||
constructor(http: HttpClient) {
|
||||
http.fetch('/api/SampleData/WeatherForecasts')
|
||||
.then(result => result.json())
|
||||
.then(data => {
|
||||
this.forecasts = data;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
interface WeatherForecast {
|
||||
dateFormatted: string;
|
||||
temperatureC: number;
|
||||
temperatureF: number;
|
||||
summary: string;
|
||||
}
|
||||
Reference in New Issue
Block a user