Files
JavaScriptServices/templates/Angular2Spa/ClientApp/app/components/fetchdata/fetchdata.component.ts
2016-09-19 15:43:58 +01:00

24 lines
553 B
TypeScript

import { Component } from '@angular/core';
import { Http } from '@angular/http';
@Component({
selector: 'fetchdata',
template: require('./fetchdata.component.html')
})
export class FetchDataComponent {
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;
}