codejump

Standalone & Tokens

Preview — 3 of 10 questions

What is runInInjectionContext used for?

ABypassing injection token resolution for testing
BCreating a child injector with additional providers
CRunning code that calls inject() outside the natural DI construction phase
DRunning code in the NgZone to trigger change detection

When would you use createEnvironmentInjector instead of runInInjectionContext?

AWhen you need to run async operations with injection
BWhen you need a persistent child injector with its own provider scope (not just a temporary context)
CWhen you want to create component-level injectors
DWhen testing services that have no constructor parameters

How does Angular handle and how should you resolve circular service dependencies?

AAngular throws a runtime error; resolve by extracting the shared logic into a third service, or use forwardRef() for class references
BAngular resolves them using a two-pass instantiation algorithm — no code change needed
CUse @Optional() on one side of the circular reference
DAngular automatically breaks cycles using lazy initialization

Sign up free to play

Answer all 10 questions (7 more), see explanations for every answer, and track your score.