28 lines
710 B
TypeScript
28 lines
710 B
TypeScript
import {Component, OnInit} from '@angular/core';
|
|
import {Region} from '../../interfaces/region.interface';
|
|
import {DataService} from '../../services/data.service';
|
|
import {Router} from '@angular/router';
|
|
|
|
@Component({
|
|
selector: 'app-home',
|
|
templateUrl: './home.component.html',
|
|
styleUrls: ['./home.component.scss']
|
|
})
|
|
export class HomeComponent implements OnInit {
|
|
|
|
private readonly MAX_REGIONS = 10;
|
|
|
|
regions: Region[];
|
|
|
|
constructor(private ds: DataService, private router: Router) {
|
|
}
|
|
|
|
async ngOnInit() {
|
|
this.regions = await this.ds.getAllRegions(this.MAX_REGIONS);
|
|
}
|
|
|
|
onRegionClick(region: Region) {
|
|
this.router.navigate(['/region', region.region_id]).catch(console.log);
|
|
}
|
|
}
|