mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
24 lines
660 B
TypeScript
24 lines
660 B
TypeScript
import { Component, Inject } from '@angular/core';
|
|
import { Http } from '@angular/http';
|
|
|
|
@Component({
|
|
selector: 'fetchdata',
|
|
templateUrl: './fetchdata.component.html'
|
|
})
|
|
export class FetchDataComponent {
|
|
public forecasts: WeatherForecast[];
|
|
|
|
constructor(http: Http, @Inject('ORIGIN_URL') originUrl: string) {
|
|
http.get(originUrl + '/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;
|
|
}
|