โ† 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. What is the purpose of enableTracing: true in RouterModule.forRoot() configuration?

    Answer: It logs all router events to the browser console for debugging

    enableTracing: true outputs every router lifecycle event to the console, making it easier to debug navigation issues during development.

  2. Which ActivatedRoute property provides an Observable that emits the URL segments for the current route?

    Answer: route.url

    ActivatedRoute.url is an Observable that emits the array of URL segments matching the current route.

  3. How can you pass static data to a route component in Angular's route configuration?

    Answer: Using the data property in the route definition

    The data property in a route definition holds a static object accessible via ActivatedRoute.data, useful for passing metadata like page titles.

  4. What does the Angular router's scrollPositionRestoration option set to 'enabled' do?

    Answer: It scrolls back to the top on forward navigation and restores position on back navigation

    With scrollPositionRestoration: 'enabled', Angular restores the saved scroll position on back/forward navigation and scrolls to the top on new navigations.

  5. In Angular, how would you define a wildcard route that catches all unmatched URLs?

    Answer: { path: '**', component: NotFoundComponent }

    The double asterisk '**' is Angular's wildcard pattern that matches any URL not handled by prior routes; it must be the last route defined.

  6. What is the CanLoad guard used for in Angular routing?

    Answer: Preventing a lazy-loaded module from being downloaded if the user lacks permission

    CanLoad prevents the Angular router from even downloading a lazy-loaded module's bundle if the guard returns false, saving bandwidth for unauthorized users.

  7. What does the router's NavigationExtras.replaceUrl option do?

    Answer: It updates the current URL without adding a new entry to the browser history stack

    Setting replaceUrl: true in NavigationExtras causes the router to replace the current browser history entry instead of pushing a new one.