We are currently using the ViewContainerRef.createComponent() method to generate components dynamically at runtime - it's sort of a plugin system, where the user can add plugins and display screens as they wish. The relevant code is here:
this.module = moduleFactory.ngModuleFactory.create(this.injector); var factory = this.module.componentFactoryResolver.resolveComponentFactory(tab.type); tab.component = this.container.createComponent(factory); Where moduleFactory is a factory to create a dynamically loaded module. If I have a directive SomeDirective I would like to apply to the created component, is this possible? The only current way I've seen is through template compilation.
Has anyone had any luck with this? I see the parameter projectableNodes: any[][] in the call to createComponent, but I have no idea if this would be relevant in this case. Thanks!