Created
March 9, 2018 19:24
-
-
Save jschwarty/9076bcfd2938b52d9749f8231ee31fb5 to your computer and use it in GitHub Desktop.
Recursive function for getting route params from the Angular router snapshot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should make a version of this that uses
paramMap
instead ofparams
.