Files
JavaScriptServices/templates/Angular2Spa/ClientApp/components/fetch-data/fetch-data.ts
2016-02-29 19:29:04 +00:00

26 lines
547 B
TypeScript

import * as ng from 'angular2/core';
import { Http } from 'angular2/http';
@ng.Component({
selector: 'fetch-data'
})
@ng.View({
template: require('./fetch-data.html')
})
export class FetchData {
public forecasts: WeatherForecast[];
constructor(http: Http) {
http.get('/api/SampleData/WeatherForecasts').subscribe(result => {
this.forecasts = result.json();
});
}
}
interface WeatherForecast {
dateFormatted: string;
temperatureC: number;
temperatureF: number;
summary: string;
}