MCPcopy Create free account
hub / github.com/angular/angular / DynamicViewport

Class DynamicViewport

packages/core/test/linker/integration_spec.ts:2473–2502  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2471}
2472
2473@Directive({
2474 selector: 'dynamic-vp',
2475})
2476class DynamicViewport {
2477 private injector: Injector;
2478 constructor(private vc: ViewContainerRef) {
2479 const myService = new MyService();
2480 myService.greeting = 'dynamic greet';
2481
2482 this.injector = Injector.create({
2483 providers: [{provide: MyService, useValue: myService}],
2484 parent: vc.injector,
2485 });
2486 }
2487
2488 create(): ComponentRef<ChildCompUsingService> {
2489 return this.vc.createComponent(ChildCompUsingService, {
2490 index: this.vc.length,
2491 injector: this.injector,
2492 });
2493 }
2494
2495 insert(viewRef: ViewRef, index?: number): ViewRef {
2496 return this.vc.insert(viewRef, index);
2497 }
2498
2499 move(viewRef: ViewRef, currentIndex: number): ViewRef {
2500 return this.vc.move(viewRef, currentIndex);
2501 }
2502}
2503
2504@Directive({
2505 selector: '[my-dir]',

Callers

nothing calls this directly

Calls 1

DirectiveClass · 0.90

Tested by

no test coverage detected