Skip to content

Commit

Permalink
chore(docs): Add params to custom RouterStateSerializer example (#589)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcabanes authored and brandonroberts committed Nov 22, 2017
1 parent 247ae1a commit a467bd6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions docs/router-store/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ import {

export interface RouterStateUrl {
url: string;
params: Params;
queryParams: Params;
}

Expand All @@ -113,12 +114,18 @@ export interface State {

export class CustomSerializer implements RouterStateSerializer<RouterStateUrl> {
serialize(routerState: RouterStateSnapshot): RouterStateUrl {
let route = routerState.root;
while (route.firstChild) {
route = route.firstChild;
}

const { url } = routerState;
const queryParams = routerState.root.queryParams;
const params = route.params;

// Only return an object including the URL and query params
// Only return an object including the URL, params and query params
// instead of the entire snapshot
return { url, queryParams };
return { url, params, queryParams };
}
}

Expand Down

0 comments on commit a467bd6

Please sign in to comment.