โ† All Angular Web Framework Flashcard Decks

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
  1. Which Angular Router guard interface should you implement to prevent a user from leaving a form with unsaved changes?

    Answer: CanDeactivate

    CanDeactivate is called before leaving a route and can prompt the user to confirm navigation away from unsaved data.

  2. What does the RouterModule.forChild() method do compared to RouterModule.forRoot()?

    Answer: It registers routes without creating a new Router service instance

    forChild() registers additional routes while reusing the single Router service instance created by forRoot().

  3. Which property of ActivatedRoute gives you a snapshot of the route params without subscribing to an Observable?

    Answer: route.snapshot.paramMap

    ActivatedRoute.snapshot provides a static snapshot of the current route state, avoiding the need for an Observable subscription.

  4. What is the purpose of the syntax in Angular templates?

    Answer: It creates a secondary or auxiliary named outlet for rendering sibling routes

    Named outlets (auxiliary outlets) allow multiple independent router outlets to be active simultaneously, each rendering different routes.

  5. In Angular routing, what does setting pathMatch: 'full' on a route accomplish?

    Answer: It requires the entire URL path to match the route's path, not just a prefix

    pathMatch: 'full' ensures the route only matches when the full URL equals the path, commonly used on empty-string redirect routes.

  6. Which method of the Router service navigates programmatically and returns a Promise?

    Answer: router.navigate()

    Router.navigate() performs programmatic navigation and returns a Promise that resolves to true on success or false if navigation was cancelled.

  7. What happens when a CanActivate guard returns an UrlTree instead of false?

    Answer: Navigation is cancelled and the router redirects to the URL represented by the UrlTree

    Returning a UrlTree from a guard cancels the current navigation and immediately starts a new navigation to the URL encoded in that UrlTree.