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
|
|
23
|
window.scroll(0,0);
|
24
|
|
25
|
this.dataService.getOverviewData().subscribe(
|
26
|
overviewData => {
|
27
|
this.overviewData = overviewData;
|
28
|
},
|
29
|
error => {
|
30
|
console.log(error);
|
31
|
}
|
32
|
);
|
33
|
}
|
34
|
|
35
|
countrySelected(countryName: string) {
|
36
|
// console.log('Country selected: ', countryName);
|
37
|
this.countrySelectedName = countryName;
|
38
|
this.countrySelectedOverview = this.overviewData.countries.filter(x => x.country === this.countrySelectedName)[0];
|
39
|
// console.log('Country selected overview: ', this.countrySelectedOverview);
|
40
|
}
|
41
|
|
42
|
deselectCountry() {
|
43
|
this.countrySelectedName = null;
|
44
|
this.countrySelectedOverview = null;
|
45
|
}
|
46
|
}
|