โ† All Angular Web Framework Flashcard Decks

Angular Professional Development 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 Professional Development flashcards as text
  1. Which Angular testing utility is used to create a testing module environment for unit testing a component?

    Answer: TestBed

    `TestBed.configureTestingModule()` sets up a miniature Angular module for testing, configuring declarations, imports, and providers.

  2. In Angular, what is the difference between `fakeAsync` and `async` test utilities?

    Answer: `fakeAsync` uses fake timers controllable with `tick()`; `async` awaits real promises

    `fakeAsync` replaces the browser timer with a simulated clock you advance via `tick()`, while `async` waits for actual asynchronous operations to complete.

  3. What does the `RouterTestingHarness` utility (Angular 15+) simplify in component tests?

    Answer: Navigating to a route and retrieving the rendered component without a real browser

    `RouterTestingHarness` provides a simple API to navigate to routes in tests and access the routed component, eliminating manual router setup boilerplate.

  4. In an Angular monorepo with Nx, what is a `buildable` library's main benefit over a regular Nx library?

    Answer: It generates its own compilable output, enabling incremental builds and build caching

    A buildable Nx library compiles to its own `dist` output, allowing the build cache to skip recompiling it when nothing has changed.

  5. Which Angular animation state transition syntax triggers an animation whenever an element enters the DOM?

    Answer: Both ':enter' and 'void => *' are equivalent

    `:enter` is an alias for `void => *`, both representing the state transition when an element is inserted into the DOM.

  6. What is the recommended approach for sharing state between sibling Angular components that are not in a parent-child relationship?

    Answer: Use a shared service with a BehaviorSubject or Signal to hold state

    A singleton service holding a `BehaviorSubject` or `Signal` is the idiomatic Angular pattern for sharing reactive state across unrelated components.

  7. Which lifecycle hook should you use to clean up subscriptions and avoid memory leaks when a component is removed from the DOM?

    Answer: ngOnDestroy

    `ngOnDestroy` is called just before Angular destroys the component, making it the correct place to call `unsubscribe()` or complete subjects.