11import { Injectable } from '@angular/core' ;
2- import { Router } from '@angular/router' ;
2+ import { NavigationExtras , Router } from '@angular/router' ;
33import { RouteService } from '../services/route.service' ;
44import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model' ;
55import { combineLatest as observableCombineLatest , Observable } from 'rxjs' ;
@@ -117,15 +117,22 @@ export class PaginationService {
117117 * @param params - The page related params to update in the route
118118 * @param extraParams - Addition params unrelated to the pagination that need to be added to the route
119119 * @param retainScrollPosition - Scroll to the pagination component after updating the route instead of the top of the page
120+ * @param navigationExtras - Extra parameters to pass on to `router.navigate`. Can be used to override values set by this service.
120121 */
121- updateRoute ( paginationId : string , params : {
122- page ?: number
123- pageSize ?: number
124- sortField ?: string
125- sortDirection ?: SortDirection
126- } , extraParams ?, retainScrollPosition ?: boolean ) {
122+ updateRoute (
123+ paginationId : string ,
124+ params : {
125+ page ?: number
126+ pageSize ?: number
127+ sortField ?: string
128+ sortDirection ?: SortDirection
129+ } ,
130+ extraParams ?,
131+ retainScrollPosition ?: boolean ,
132+ navigationExtras ?: NavigationExtras ,
133+ ) {
127134
128- this . updateRouteWithUrl ( paginationId , [ ] , params , extraParams , retainScrollPosition ) ;
135+ this . updateRouteWithUrl ( paginationId , [ ] , params , extraParams , retainScrollPosition , navigationExtras ) ;
129136 }
130137
131138 /**
@@ -135,13 +142,21 @@ export class PaginationService {
135142 * @param params - The page related params to update in the route
136143 * @param extraParams - Addition params unrelated to the pagination that need to be added to the route
137144 * @param retainScrollPosition - Scroll to the pagination component after updating the route instead of the top of the page
145+ * @param navigationExtras - Extra parameters to pass on to `router.navigate`. Can be used to override values set by this service.
138146 */
139- updateRouteWithUrl ( paginationId : string , url : string [ ] , params : {
140- page ?: number
141- pageSize ?: number
142- sortField ?: string
143- sortDirection ?: SortDirection
144- } , extraParams ?, retainScrollPosition ?: boolean ) {
147+ updateRouteWithUrl (
148+ paginationId : string ,
149+ url : string [ ] ,
150+ params : {
151+ page ?: number
152+ pageSize ?: number
153+ sortField ?: string
154+ sortDirection ?: SortDirection
155+ } ,
156+ extraParams ?,
157+ retainScrollPosition ?: boolean ,
158+ navigationExtras ?: NavigationExtras ,
159+ ) {
145160 this . getCurrentRouting ( paginationId ) . subscribe ( ( currentFindListOptions ) => {
146161 const currentParametersWithIdName = this . getParametersWithIdName ( paginationId , currentFindListOptions ) ;
147162 const parametersWithIdName = this . getParametersWithIdName ( paginationId , params ) ;
@@ -152,12 +167,14 @@ export class PaginationService {
152167 this . router . navigate ( url , {
153168 queryParams : queryParams ,
154169 queryParamsHandling : 'merge' ,
155- fragment : `p-${ paginationId } `
170+ fragment : `p-${ paginationId } ` ,
171+ ...navigationExtras ,
156172 } ) ;
157173 } else {
158174 this . router . navigate ( url , {
159175 queryParams : queryParams ,
160- queryParamsHandling : 'merge'
176+ queryParamsHandling : 'merge' ,
177+ ...navigationExtras ,
161178 } ) ;
162179 }
163180 this . clearParams = { } ;
0 commit comments