DI error in subcomponent

313 Views Asked by At

I'm developing a (really) huge Angular 2 application as an internal tool for my company. The application is made up of different sub-applications, that can be accessed only by certain users.

In order to do this, I tried using a CanActivate class returning an observable, querying one of my services to verify access, but the contructor for the class is invalidated when I try to import the service.

So I moved the test in the application itself, but it failed the same way. So it's likely that the problem is in the service itself. The very strange thing is that the apps container is using the same service, wihout any problem at all (the service is also providing the list of the available application, generating the apps menu).

I'm quite sure that the problem is the loading order of the components (and probably is Http-related), but I have no idea where to look. Sadly, given the complexity of the application, it's very hard for me to isolate the problem and I don't know what to do.

I searched for similar problems and found similar situations, but the Angular2 development has moved forward in the meantime and those solutions have become useless.

1

There are 1 best solutions below

0
On

I spent the whole day on this problem but I figured it out.... almost.
It wasn't DI-related but something as wrong with a const import (of course, the error given was absolutely misleading), I really have no idea why. I moved it and now it works properly. Thank you anyway.