Add AureliaSpa template (#398)

This commit is contained in:
kmkatsma
2016-10-28 11:16:21 +01:00
committed by SteveSandersonMS
parent 867e60d7fd
commit e60ea04f86
31 changed files with 722 additions and 0 deletions

View File

@@ -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>

View File

@@ -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;
}