mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
24 lines
688 B
TypeScript
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;
|
|
}
|