Route Config & Links — Series 2

Preview — 3 of 10 questions

Which produces /heroes/42/edit?

javascript
<a [routerLink]="['/heroes', hero.id, 'edit']">Edit</a>
<a [routerLink]="['/search']" [queryParams]="{ q: term }" fragment="results">Search</a>
ArouterLink="/heroes/{{ id }}/edit" only
B[routerLink]="['/heroes', id, 'edit']" — the array form, where each element is a path segment and non-string values are stringified and URL-encoded
C[routerLink]="'/heroes/' + id + '/edit'" is the only supported dynamic form
D[routerLink]="{ path: '/heroes', id }"

What does this do?

javascript
{ path: 'heroes', component: HeroList, title: 'Heroes — Codejump' }
AIt sets a heading rendered above the routed component
BIt sets the document.title on navigation, through the router's built-in TitleStrategy — no manual Title service call needed
CIt is metadata for guards only
DIt sets the browser tab's favicon tooltip

Why does nothing render for /heroes/42?

javascript
{ path: 'heroes', component: HeroList, children: [{ path: ':id', component: HeroDetail }] }
ABecause HeroList's template has no <router-outlet> for the child to render into
BBecause child routes require loadChildren
CBecause :id must be declared before the parent
DBecause children cannot use component

Sign up free to play

Answer all 10 questions (7 more), see explanations for every answer, and track your score.