- Timestamp:
- 08/07/20 10:59:56 (5 years ago)
- Branches:
- master
- Children:
- 63d885e
- Parents:
- c73269d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Farmatiko/ClientApp/src/app/korona/korona.component.ts
rc73269d ree137aa 1 import { Component, OnInit, Inject } from '@angular/core'; 2 import { Pandemic } from '../models/Pandemic'; 3 import { MatTableDataSource } from '@angular/material/table'; 4 import { HttpClient } from '@angular/common/http'; 1 import { Component, OnInit } from '@angular/core'; 2 import { DataService } from '../shared/data.service'; 3 import { IPandemic } from '../shared/interfaces'; 5 4 6 5 @Component({ … … 10 9 }) 11 10 export class KoronaComponent implements OnInit { 12 public korona: Pandemic[];11 public korona: IPandemic; 13 12 14 constructor(http: HttpClient, @Inject('BASE_URL') baseUrl: string) { 15 http.get<Pandemic[]>(baseUrl + 'Pandemic/Get?').subscribe(result => { 16 this.korona = result; 17 console.log(this.korona); 18 }, error => console.error(error)); 13 constructor(private dataService: DataService) { 14 19 15 } 20 16 21 17 ngOnInit(): void { 18 this.dataService.getPandemic() 19 .subscribe((res: IPandemic) => { 20 this.korona = res; 21 }, 22 (err: any) => console.log(err), 23 () => console.log('Pandemic data retrieved')); 22 24 } 23 25
Note:
See TracChangeset
for help on using the changeset viewer.