Last change
on this file since fbaea22 was 30a465f, checked in by DimitarSlezenkovski <dslezenkovski@…>, 4 years ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
612 bytes
|
Line | |
---|
1 | import { Component, Inject } from '@angular/core';
|
---|
2 | import { HttpClient } from '@angular/common/http';
|
---|
3 |
|
---|
4 | @Component({
|
---|
5 | selector: 'app-fetch-data',
|
---|
6 | templateUrl: './fetch-data.component.html'
|
---|
7 | })
|
---|
8 | export class FetchDataComponent {
|
---|
9 | public forecasts: WeatherForecast[];
|
---|
10 |
|
---|
11 | constructor(http: HttpClient, @Inject('BASE_URL') baseUrl: string) {
|
---|
12 | http.get<WeatherForecast[]>(baseUrl + 'weatherforecast').subscribe(result => {
|
---|
13 | this.forecasts = result;
|
---|
14 | }, error => console.error(error));
|
---|
15 | }
|
---|
16 | }
|
---|
17 |
|
---|
18 | interface WeatherForecast {
|
---|
19 | date: string;
|
---|
20 | temperatureC: number;
|
---|
21 | temperatureF: number;
|
---|
22 | summary: string;
|
---|
23 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.