Project

General

Profile

1
import { Component, DoCheck, OnInit, ViewEncapsulation } from '@angular/core';
2
import { DataService } from '../../services/data.service';
3
import { CountryOverview, OverviewData } from '../../domain/overview-data';
4

    
5
@Component({
6
  selector: 'app-home',
7
  templateUrl: './home.component.html',
8
  // styleUrls: ['./top-menu.component.css'],
9
  encapsulation: ViewEncapsulation.None
10
})
11

    
12
export class HomeComponent implements OnInit {
13

    
14
  overviewData: OverviewData;
15

    
16
  countrySelectedName: string = null;
17
  countrySelectedOverview: CountryOverview = null;
18

    
19
  constructor(private dataService: DataService) { }
20

    
21
  ngOnInit(): void {
22
    this.dataService.getOverviewData().subscribe(
23
      overviewData => {
24
        this.overviewData = overviewData;
25
      },
26
      error => {
27
        console.log(error);
28
      }
29
    );
30
  }
31

    
32
  countrySelected(countryName: string) {
33
    // console.log('Country selected: ', countryName);
34
    this.countrySelectedName = countryName;
35
    this.countrySelectedOverview = this.overviewData.countries.filter(x => x.country === this.countrySelectedName)[0];
36
    // console.log('Country selected overview: ', this.countrySelectedOverview);
37
  }
38

    
39
  deselectCountry() {
40
    this.countrySelectedName = null;
41
    this.countrySelectedOverview = null;
42
  }
43
}
(10-10/10)