11 / 11

How do you make a provider accessible across the entire module graph using ModuleRef.get() with strict: false?

By default, moduleRef.get(token) only searches the current module's provider registry. Passing { strict: false } makes it search the entire global module graph. This should be used sparingly as it breaks module encapsulation and makes dependencies invisible in the module metadata.

Using strict: false with ModuleRef
When to use and when to avoid:
  1. 1

    Use strict: false only when the provider cannot be imported through the normal module graph.

  2. 2

    Prefer explicit module imports and exports over strict: false — they keep dependencies traceable.

  3. 3

    strict: false is useful in dynamic plugin systems or framework-level utilities.

  4. 4

    strict: false only works for singleton providers — scoped providers require moduleRef.resolve().