I'm creating components dynamically but when I try to do it with a directive I failed. How can I create/instantiate a directive dynamically and assign/associate it with a component?
I create components in the following way:
createComponent(anyViewContainer: ViewContainerRef, aComponentClass: Type<any>) {
const aComponentFact = this.componentFactoryResolver.resolveComponentFactory(aComponentClass);
const aComponentRefs = anyViewContainer.createComponent(aComponentFact);
return aComponentRefs;
}