Question presented to candidate:
"Walk me through what happens when Angular meets a @defer block, then list the triggers you can use, and pick the right one for: a below-the-fold reviews section, a settings panel behind a button, and a chat widget that should load once the page is quiet."
What a strong answer should cover:
- The sequence: placeholder rendered, trigger fires, dependency function loads code, content swaps in (or
@error). ontriggers:idle(default),immediate,timer(...),viewport,interaction,hover; targets via template references.when expr: loads when truthy, one-shot.- Multiple triggers are OR-ed;
prefetchandhydratevariants are separate families. - Sensible choices: viewport for reviews, interaction/hover (+ prefetch on hover) for the panel, idle or timer for the chat widget.
- Constraints: triggers without a target need a
@placeholder;viewportneedsIntersectionObserver.
Clarifying questions expected:
- "Is the page server-rendered? Then hydrate triggers may matter too."
Code / implementation expected: Yes — a template with several @defer blocks using different triggers.