โ† All Angular Web Framework Flashcard Decks

Angular Advanced Practice 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 Angular Advanced Practice flashcards as text
  1. What Angular feature allows you to write `@if`, `@for`, and `@switch` directly in templates without importing `NgIf`, `NgFor`, or `NgSwitch` directives?

    Answer: Built-in control flow (Angular 17+)

    Angular 17 introduced built-in control flow syntax (@if, @for, @switch) that is compiled directly by the framework without needing CommonModule or directive imports.

  2. What is the primary benefit of using `inject()` function instead of constructor-based injection in Angular services and components?

    Answer: It allows injection outside of class constructors, such as in functions and field initializers

    The inject() function can be called in an injection context (constructor, field initializer, factory function) and enables functional patterns without needing class constructors.

  3. In Angular's HttpClient, which operator or mechanism should you use to retry a failed HTTP request up to 3 times with a delay between retries?

    Answer: retry(3) from RxJS

    The RxJS retry(3) operator resubscribes to the source Observable (the HTTP call) up to 3 times on error, and retry({ count: 3, delay: 1000 }) adds a delay.

  4. Which Angular Signal API allows you to create a derived reactive value that recomputes automatically when its dependencies change?

    Answer: computed()

    computed() creates a read-only Signal whose value is lazily recalculated whenever any of the Signals it reads inside its function change.

  5. What does the `resolveComponentFactory` approach get replaced by in modern Angular when dynamically creating components?

    Answer: ViewContainerRef.createComponent() with a component class directly

    Since Angular 13, ViewContainerRef.createComponent(MyComponent) accepts the component class directly without needing ComponentFactoryResolver or resolveComponentFactory.

  6. What is the purpose of the `provideHttpClient(withInterceptorsFromDi())` call used in standalone Angular applications?

    Answer: Registers HttpClient and supports class-based DI interceptors in the standalone bootstrap setup

    provideHttpClient() configures HttpClient for standalone apps, and withInterceptorsFromDi() enables the older class-based HTTP_INTERCEPTORS token alongside functional interceptors.

  7. When using Angular's `Router` with `preloadingStrategy`, what does `PreloadAllModules` do?

    Answer: Loads all lazy modules in the background after the initial page load completes

    PreloadAllModules starts background loading of all lazy-loaded route modules after the initial navigation succeeds, so future navigations are nearly instant.