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

Class DynamicViewport

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

Source from the content-addressed store, hash-verified

2270}
2271
2272@Directive({
2273 selector: 'dynamic-vp',
2274 standalone: false,
2275})
2276class DynamicViewport {
2277 private injector: Injector;
2278 constructor(private vc: ViewContainerRef) {
2279 const myService = new MyService();
2280 myService.greeting = 'dynamic greet';
2281
2282 this.injector = Injector.create({
2283 providers: [{provide: MyService, useValue: myService}],
2284 parent: vc.injector,
2285 });
2286 }
2287
2288 create(): ComponentRef<ChildCompUsingService> {
2289 return this.vc.createComponent(ChildCompUsingService, {
2290 index: this.vc.length,
2291 injector: this.injector,
2292 });
2293 }
2294
2295 insert(viewRef: ViewRef, index?: number): ViewRef {
2296 return this.vc.insert(viewRef, index);
2297 }
2298
2299 move(viewRef: ViewRef, currentIndex: number): ViewRef {
2300 return this.vc.move(viewRef, currentIndex);
2301 }
2302}
2303
2304@Directive({
2305 selector: '[my-dir]',

Callers

nothing calls this directly

Calls 1

DirectiveClass · 0.90

Tested by

no test coverage detected