travopti/frontend/src/app/containers/region-details/region-details.component.ts
2020-06-18 13:26:32 +02:00

32 lines
928 B
TypeScript

import {Component, OnInit} from '@angular/core';
import {Region} from '../../interfaces/region.interface';
import {ActivatedRoute, ParamMap} from '@angular/router';
import {DataService} from '../../services/data.service';
import {switchMap} from 'rxjs/operators';
@Component({
selector: 'app-region-details',
templateUrl: './region-details.component.html',
styleUrls: ['./region-details.component.scss']
})
export class RegionDetailsComponent implements OnInit {
/** Cut descriptions after x chars */
readonly DESC_CUT_POINT = 300;
/** Current region */
region: Region;
/** Extend the description text */
isDescExtended = false;
constructor(private route: ActivatedRoute, private ds: DataService) {
}
ngOnInit() {
this.route.paramMap.pipe(
switchMap((params: ParamMap) => this.ds.getRegion(parseInt(params.get('id'), 10)))
).subscribe((region: Region) => this.region = region);
}
}