โ† All Angular Web Framework Flashcard Decks

Components & Templates 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 Components & Templates flashcards as text
  1. What is a standalone component in Angular?

    Answer: A component that declares its own dependencies without an NgModule

    Standalone components use `standalone: true` and list their own imports, removing the requirement to be declared in an NgModule.

  2. In Angular's template, what does the safe navigation operator (`?.`) prevent?

    Answer: Null or undefined property access that would throw an error

    The ?. operator short-circuits the expression if the left-hand side is null or undefined, preventing template errors.

  3. What ViewEncapsulation mode causes Angular to emit styles globally without any scoping?

    Answer: None

    ViewEncapsulation.None adds component styles to the global stylesheet with no attribute-based scoping applied.

  4. Which hook would you use to clean up subscriptions or timers before a component is removed from the DOM?

    Answer: ngOnDestroy

    ngOnDestroy is called just before Angular destroys the component, making it the correct place to cancel subscriptions and clear intervals.

  5. What does `@ContentChildren(ItemComponent)` return inside a component?

    Answer: A QueryList of all projected ItemComponent instances

    @ContentChildren queries projected content and returns a live QueryList containing all matching component or directive instances.

  6. What Angular template syntax enables two-way data binding on a form input using `ngModel`?

    Answer: [(ngModel)]="value"

    The banana-in-a-box syntax [(ngModel)] combines property binding [ ] and event binding ( ) for two-way synchronization.

  7. If a child component receives a new object reference via @Input but ChangeDetectionStrategy.OnPush is set, will it re-render?

    Answer: Yes, because a new object reference triggers OnPush change detection

    OnPush runs change detection when an @Input receives a new reference, so replacing the whole object (immutable update) triggers re-render.