All quizzesHard
Router Internals — Series 2
Preview — 3 of 10 questions
What does matcher replace, and what must it return?
javascript
{ matcher: yearMatcher, component: ArchivePage }AIt replaces path: a function deciding whether a segment run matches, returning { consumed, posParams } — or null for no match — which allows patterns path cannot express, such as a four-digit year
BIt replaces canMatch; it returns a boolean
CIt replaces redirectTo and returns a UrlTree
DIt post-processes the matched URL after activation
What does parseUrl return for /a/b?x=1#frag?
javascript
const tree = this.router.parseUrl('/a/b?x=1#frag');
tree.root.children['primary'].segments.map((s) => s.path); // ['a', 'b']
tree.queryParams; // { x: '1' }
tree.fragment; // 'frag'
this.router.serializeUrl(tree); // back to a stringAA string array of segments
BA tree: a root UrlSegmentGroup with children keyed by outlet name (primary here), each holding UrlSegments with their matrix parameters, plus queryParams and fragment on the tree itself
CA flat object of parameters
DThe ActivatedRouteSnapshot for that URL
What does this URL activate?
javascript
/inbox(popup:compose)AA query parameter named popup
BA route whose path is literally inbox(popup:compose)
CTwo routes at once: inbox in the primary outlet and compose in the outlet named popup — the parenthesised syntax is how auxiliary outlets appear in the URL
DA redirect from inbox to compose
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.