OasisDigital / ng-doc-portal

An Nx plugin & Angular module set that allows you to build documentation applications natively in Angular! This project has a focus on documenting Angular components (e.g. component library), but it can be used for any documentation needs you might have in Angular.
3 stars 0 forks source link

Nested DI fails to find injectable #6

Closed zjkipping closed 1 year ago

zjkipping commented 1 year ago

In a situation where a doc-page component injects a service that injects yet another service, the DI chain completely breaks. This happened in the case of a custom modal system that piggy backs on top of the Angular CDK Dialog system. The "Dialog" provider could never be found.

A workaround is manually providing the service that is injected into doc-page component. So, in this case manually providing the ModalService inside our doc-page's provider list.

zjkipping commented 1 year ago

Have been able to reproduce this issue inside the ng-doc-portal repo.

Going to try and convert the generated angular application that our plugin creates to fully use standalone components. Instead of only have the doc-page components be standalone.

zjkipping commented 1 year ago

This seems to be an issue with how angular does the DI for standalone components when mixed with modules.

I went ahead and pushed v1.5.0 that converted everything in the packages to standalone. See the release notes here.

When on v1.5.0 the solution to this specific problem is to do importProvidersFrom(DialogModule) in the main.ts's bootstrapApplication's environment providers list.