24 lines
670 B
TypeScript
24 lines
670 B
TypeScript
import { Injectable } from '@angular/core';
|
|
import { ActivatedRoute, UrlSegment } from '@angular/router';
|
|
|
|
import { LoaderService } from './loader.service';
|
|
import { PollService } from './poll.service';
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class UrlService {
|
|
constructor(
|
|
private route: ActivatedRoute,
|
|
private pollService: PollService,
|
|
private loaderService: LoaderService
|
|
) {}
|
|
|
|
public async loadPollFromUrl(): Promise<void> {
|
|
this.loaderService.setStatus(true);
|
|
const wantedSlug: string = this.route.snapshot.firstChild.firstChild.url[1].path;
|
|
await this.pollService.getPollByIdentifier(wantedSlug);
|
|
this.loaderService.setStatus(false);
|
|
}
|
|
}
|