import { Params , RouterStateSnapshot } from '@angular/router' ; import { RouterStateSerializer } from '@ngxs/router-plugin' ; export interface RouterStateParams { root : { url : string ; params : Params ; queryParams : Params ; data : any ; } ; } export class CustomRouterStateSerializer implements RouterStateSerializer < RouterStateParams > { serialize ( routerState ) { const { url , root : { queryParams } , } = routerState ; let { root : route } = routerState ; while ( route . firstChild ) { route = route . firstChild ; } const { params , data } = route ; return { root : { url , params , queryParams , data } } ; } }