Last active
September 15, 2018 08:45
-
-
Save nathan-lapinski/27d3dd58b576001ac2269153bf54e936 to your computer and use it in GitHub Desktop.
playing with urls and the router
This file contains 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
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