mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-24 02:30:13 +00:00
Initial KnockoutSpa template
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import * as ko from 'knockout';
|
||||
|
||||
interface WeatherForecast {
|
||||
dateFormatted: string;
|
||||
temperatureC: number;
|
||||
temperatureF: number;
|
||||
summary: string;
|
||||
}
|
||||
|
||||
class FetchDataViewModel {
|
||||
public forecasts = ko.observableArray<WeatherForecast>();
|
||||
|
||||
constructor() {
|
||||
fetch('/api/SampleData/WeatherForecasts')
|
||||
.then(response => response.json())
|
||||
.then((data: WeatherForecast[]) => {
|
||||
this.forecasts(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default { viewModel: FetchDataViewModel, template: require('./fetch-data.html') };
|
||||
Reference in New Issue
Block a user