Commits
Luca Giamminonni authored 5d8d3e35d58
1 + | import { Injectable } from '@angular/core'; |
2 + | import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router'; |
3 + | |
4 + | /** |
5 + | * Interface for the route parameters. |
6 + | */ |
7 + | export interface AdminNotificationsSuggestionTargetsPageParams { |
8 + | pageId?: string; |
9 + | pageSize?: number; |
10 + | currentPage?: number; |
11 + | } |
12 + | |
13 + | /** |
14 + | * This class represents a resolver that retrieve the route data before the route is activated. |
15 + | */ |
16 + | @Injectable() |
17 + | export class AdminNotificationsSuggestionTargetsPageResolver implements Resolve<AdminNotificationsSuggestionTargetsPageParams> { |
18 + | |
19 + | /** |
20 + | * Method for resolving the parameters in the current route. |
21 + | * @param {ActivatedRouteSnapshot} route The current ActivatedRouteSnapshot |
22 + | * @param {RouterStateSnapshot} state The current RouterStateSnapshot |
23 + | * @returns AdminNotificationsSuggestionTargetsPageParams Emits the route parameters |
24 + | */ |
25 + | resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): AdminNotificationsSuggestionTargetsPageParams { |
26 + | return { |
27 + | pageId: route.queryParams.pageId, |
28 + | pageSize: parseInt(route.queryParams.pageSize, 10), |
29 + | currentPage: parseInt(route.queryParams.page, 10) |
30 + | }; |
31 + | } |
32 + | } |