diff --git a/packages/core/src/di/injector_compatibility.ts b/packages/core/src/di/injector_compatibility.ts index e1e054dd145..2bd1d32c606 100644 --- a/packages/core/src/di/injector_compatibility.ts +++ b/packages/core/src/di/injector_compatibility.ts @@ -55,7 +55,7 @@ export function injectInjectorOnly(token: ProviderToken, flags = InjectFla null { if (_currentInjector === undefined) { const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ? - `inject() must be called from an injection context` : + `inject() must be called from an injection context (a constructor, a factory function or a field initializer)` : ''; throw new RuntimeError(RuntimeErrorCode.MISSING_INJECTION_CONTEXT, errorMessage); } else if (_currentInjector === null) {