@Component({
selector: 'a-component',
template: `
<ng-template #dynamicFilterConditionComponent></ng-template>
`
})
export class Acomponent implements OnInit {
@ViewChild('dynamicComponent', { static: true, read: ViewContainerRef }) dynamicComponent: ViewContainerRef;
componentRef: ComponentRef<any>;
key:string;
componentsMap = {
[ConfigTypeKeyEnum.SEARCH_SCOPE]: SearchScopeComponent
};
constructor() {}
ngOnInit(): void {
this.createComponent();
}
createComponent() {
this.clearComponent();
this.componentRef = this.filterComponent.createComponent(this.componentsMap[this.type]);
this.componentRef.instance.key = this.key;
this.componentRef.instance.valueChange.subscribe((query) => {
});
}
clearComponent() {
this.filterComponent.clear();
}
}