import { Component, ComponentFactoryResolver, ComponentRef, ViewContainerRef } from '@angular/core'; import * as i0 from "@angular/core"; /** * Insert a component dynamically using a service * ### Example ```ts import { DynamicComponentService } from './dynamic.component.service'; import { MyDynamicComponent } from './my-1.component'; @Component({ template: ` ...
` }) export class MyComponent { @ViewChild('dynamic', {read:ViewContainerRef}) vcr: ViewContainerRef; constructor(public dcs: DynamicComponentService) {} insertComp() { let compRef = this.dcs.createComponent(MyDynamicComponent, this.vcr); ths.dcs.insertComonent(cmpRef); compRef.instance.items = [1,2,3]; // dealing with @input compRef.instance.output$.subscribe(val => {}); // dealing with @output } } ``` */ export declare class DynamicComponentService { /** used to create a factory from a component class */ factoryResolver: ComponentFactoryResolver; /** defines where a dynamic components insert into */ rootViewContainer: ViewContainerRef; constructor(factoryResolver: any); /** * returns component reference * The reason to seperate `createCompnent` and `insertComponent` is * to allow some actions before we insert into a hostView. * e.g styling, setting attributes, etc */ createComponent(component: any, into?: ViewContainerRef): ComponentRef; /** * insert component */ insertComponent(componentRef: ComponentRef): Component; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; }