Routing & Navigation Flashcards
7 cards from real Angular Web Framework practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 7 Routing & Navigation flashcards as text
In an Angular lazy-loaded route configuration, what does the loadChildren property accept in modern Angular (v9+)?
Answer: A dynamic import() returning a module with routing
Modern Angular uses dynamic import() syntax like () => import('./feature/feature.module').then(m => m.FeatureModule) for lazy loading.
What is the role of a Resolve guard in Angular routing?
Answer: It pre-fetches route data before the component is activated
A Resolve guard fetches data before the route is activated, making that data available via ActivatedRoute.data when the component renders.
How do you access query parameters from a route URL like /search?q=angular using ActivatedRoute?
Answer: route.queryParamMap.get('q') via subscription or snapshot
Query parameters are accessed via route.queryParamMap (Observable) or route.snapshot.queryParamMap using the .get() method.
Which Angular routing event fires immediately after navigation successfully completes?
Answer: NavigationEnd
NavigationEnd is emitted by the Router's events Observable when a navigation completes successfully and the URL has been committed.
What does relativeTo option do in Router.navigate() calls?
Answer: It navigates relative to a specified ActivatedRoute instead of the root
The relativeTo option allows navigation using paths relative to a given ActivatedRoute, enabling context-aware navigation within component trees.
In Angular route configuration, what is the difference between 'children' and 'loadChildren'?
Answer: children loads routes eagerly at app startup; loadChildren defers module loading until the route is first visited
children defines eagerly loaded child routes inline, while loadChildren enables lazy loading by deferring the import of a feature module until needed.
What Angular decorator is used to mark a class as a route guard implementing CanActivate?
Answer: @Injectable()
Route guards are Angular services decorated with @Injectable(), allowing them to be injected into the router's DI system.