Files
JavaScriptServices/templates/AngularSpa/ClientApp/app/components/fetchdata/fetchdata.component.ts
2017-08-02 10:55:55 +01:00

24 lines
688 B
TypeScript

import { Component, Inject } from '@angular/core';
import { HttpWithStateTransfer } from 'aspnet-angular';
@Component({
selector: 'fetchdata',
templateUrl: './fetchdata.component.html'
})
export class FetchDataComponent {
public forecasts: WeatherForecast[];
constructor(http: HttpWithStateTransfer, @Inject('BASE_URL') baseUrl: string) {
http.get(baseUrl + 'api/SampleData/WeatherForecasts').subscribe(result => {
this.forecasts = result.json() as WeatherForecast[];
}, error => console.error(error));
}
}
interface WeatherForecast {
dateFormatted: string;
temperatureC: number;
temperatureF: number;
summary: string;
}