Skip to content

Instantly share code, notes, and snippets.

@jschwarty
Created March 9, 2018 19:24
Show Gist options
  • Save jschwarty/9076bcfd2938b52d9749f8231ee31fb5 to your computer and use it in GitHub Desktop.
Save jschwarty/9076bcfd2938b52d9749f8231ee31fb5 to your computer and use it in GitHub Desktop.
Recursive function for getting route params from the Angular router snapshot
import { ActivatedRoute } from '@angular/router';
export function getFullTreeParams(route: ActivatedRoute, params = {}) {
if (route) {
params = {...params, ...route.snapshot.params};
}
return route.parent
? this.getFullTreeParams(route.parent, params)
: params;
}
@jschwarty
Copy link
Author

Should make a version of this that uses paramMap instead of params.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment