MCPcopy Index your code
hub / github.com/angular/angular / TestCmp

Class TestCmp

packages/core/test/acceptance/environment_injector_spec.ts:215–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213 });
214
215 @Component({
216 template: '',
217 providers: [{provide: TOKEN, useValue: 'from component'}],
218 })
219 class TestCmp {
220 envInjector = inject(EnvironmentInjector);
221
222 tokenFromComponent = inject(TOKEN);
223 tokenFromEnvContext = this.envInjector.runInContext(() => inject(TOKEN));
224
225 // Attempt to inject ViewContainerRef within the environment injector's context. This should
226 // not be available, so the result should be `null`.
227 vcrFromEnvContext = this.envInjector.runInContext(() =>
228 inject(ViewContainerRef, {optional: true}),
229 );
230 }
231
232 const instance = TestBed.createComponent(TestCmp).componentInstance;
233 expect(instance.tokenFromComponent).toEqual('from component');

Callers

nothing calls this directly

Calls 3

ComponentInterface · 0.90
injectFunction · 0.90
runInContextMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…