Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
playing with urls and the router
const url = '/users/1/notes/42(sidebar:secondary1)?lang=en#line99';
const tree = this.router.parseUrl(url); // '/users/1/notes/42(sidebar:secondary1)?lang=en#line99'
const fragment = tree.fragment; // line99
const queryParams = tree.queryParams; // lang=en
const primary: UrlSegmentGroup = tree.root.children[PRIMARY_OUTLET]; // gets the UrlSegmentGroup for the primary router outlet
const sidebar: UrlSegmentGroup = tree.root.children['sidebar']; // gets the UrlSegmentGroup for the secondary router outlet (sidebar)
const primarySegments: UrlSegment[] = primary.segments; // returns all UrlSegments for the primary outlet. ['users','1','notes','42']
const sidebarSegments: UrlSegment[] = sidebar.segments; // returns all UrlSegments for the secondary outlet. ['secondary1']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.