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' ;
@@ -114,15 +114,22 @@ export class PaginationService {
114114 * @param params - The page related params to update in the route
115115 * @param extraParams - Addition params unrelated to the pagination that need to be added to the route
116116 * @param retainScrollPosition - Scroll to the pagination component after updating the route instead of the top of the page
117+ * @param navigationExtras - Extra parameters to pass on to `router.navigate`. Can be used to override values set by this service.
117118 */
118- updateRoute ( paginationId : string , params : {
119- page ?: number
120- pageSize ?: number
121- sortField ?: string
122- sortDirection ?: SortDirection
123- } , extraParams ?, retainScrollPosition ?: boolean ) {
119+ updateRoute (
120+ paginationId : string ,
121+ params : {
122+ page ?: number
123+ pageSize ?: number
124+ sortField ?: string
125+ sortDirection ?: SortDirection
126+ } ,
127+ extraParams ?,
128+ retainScrollPosition ?: boolean ,
129+ navigationExtras ?: NavigationExtras ,
130+ ) {
124131
125- this . updateRouteWithUrl ( paginationId , [ ] , params , extraParams , retainScrollPosition ) ;
132+ this . updateRouteWithUrl ( paginationId , [ ] , params , extraParams , retainScrollPosition , navigationExtras ) ;
126133 }
127134
128135 /**
@@ -132,13 +139,21 @@ export class PaginationService {
132139 * @param params - The page related params to update in the route
133140 * @param extraParams - Addition params unrelated to the pagination that need to be added to the route
134141 * @param retainScrollPosition - Scroll to the pagination component after updating the route instead of the top of the page
142+ * @param navigationExtras - Extra parameters to pass on to `router.navigate`. Can be used to override values set by this service.
135143 */
136- updateRouteWithUrl ( paginationId : string , url : string [ ] , params : {
137- page ?: number
138- pageSize ?: number
139- sortField ?: string
140- sortDirection ?: SortDirection
141- } , extraParams ?, retainScrollPosition ?: boolean ) {
144+ updateRouteWithUrl (
145+ paginationId : string ,
146+ url : string [ ] ,
147+ params : {
148+ page ?: number
149+ pageSize ?: number
150+ sortField ?: string
151+ sortDirection ?: SortDirection
152+ } ,
153+ extraParams ?,
154+ retainScrollPosition ?: boolean ,
155+ navigationExtras ?: NavigationExtras ,
156+ ) {
142157 this . getCurrentRouting ( paginationId ) . subscribe ( ( currentFindListOptions ) => {
143158 const currentParametersWithIdName = this . getParametersWithIdName ( paginationId , currentFindListOptions ) ;
144159 const parametersWithIdName = this . getParametersWithIdName ( paginationId , params ) ;
@@ -149,12 +164,14 @@ export class PaginationService {
149164 this . router . navigate ( url , {
150165 queryParams : queryParams ,
151166 queryParamsHandling : 'merge' ,
152- fragment : `p-${ paginationId } `
167+ fragment : `p-${ paginationId } ` ,
168+ ...navigationExtras ,
153169 } ) ;
154170 } else {
155171 this . router . navigate ( url , {
156172 queryParams : queryParams ,
157- queryParamsHandling : 'merge'
173+ queryParamsHandling : 'merge' ,
174+ ...navigationExtras ,
158175 } ) ;
159176 }
160177 this . clearParams = { } ;
0 commit comments