I am getting a NullInjectorError error when I use an Angular component in a federated module (via remoteEntry.js), while it is working well in a standalone Angualar app.

It is (and has to be) a standalone angular component.

The service that I am injecting is declared via an abstract class (declared in the same Angular component library project), while the specific implementation is declared in a module in another project (to be able to have different implementations of the data access, depending on the environment, where the micro-frontend or the specific individual component is deployed).

I've built a repro sample. And here is the module/class/service design diagram: enter image description here

But I am getting:

NullInjectorError: R3InjectorError(Standalone[FeatureComponent])[MassCommunicationService -> MassCommunicationService -> MassCommunicationService -> HelloService -> HelloService]: 
  NullInjectorError: No provider for HelloService!

Following repo shows the step-by-step configuration of the app shell and the federated module (both pretty standard) as per this article: Dynamic Module Federation with Angular.

Least reproducible sample: https://github.com/jan-dolejsi/angular-module-federation-sample/tree/service-to-service-injection

Note that the main branch has the last working version (without the service-to-service injection) for comparison.

Answers provided elsewhere:

Is this an impossible ask? A generic shared component with injectable service implementation provided by a module that is loaded via remoteEntry.js?

Help appreciated.

0

There are 0 best solutions below