gund / ng-dynamic-component

Dynamic components with full life-cycle support for inputs and outputs for Angular
https://malkevich-alex.gitbook.io/ng-dynamic-component/
MIT License
561 stars 65 forks source link

Ability to provide ngModuleRef when creating component #494

Closed msgoloborodov closed 1 year ago

msgoloborodov commented 1 year ago

Can you add ability to provide ngModuleRef or environmentInjector to ViewContainerRef.createComponent options: https://angular.io/api/core/ViewContainerRef#createComponent ngModuleRef: an NgModuleRef of the component's NgModule, you should almost always provide this to ensure that all expected providers are available for the component instantiation. It is very important when creating component declared in lazy loaded module to properly resolving dependencies.

gund commented 1 year ago

If you are using ngComponentOutlet directive from Angular you already can provide NgModule there.

Or are you talking about ndc-dynamic component from this library specifically?

msgoloborodov commented 1 year ago

Yes. I'm talking about ndc-dynamic. https://github.com/gund/ng-dynamic-component/pull/495

msgoloborodov commented 1 year ago

If you are using ngComponentOutlet directive from Angular you already can provide NgModule there.

Or are you talking about ndc-dynamic component from this library specifically?

You are right. I think it's better to use ngComponentOutlet and ndcDynamicInputs/ndcDynamicOutputs if needed.

gund commented 1 year ago

This has been released in https://github.com/gund/ng-dynamic-component/pull/495 and available in v10.6.0