1

I am using Ionic 2 and have some problems with providers/injections since version 2.0.0. The error I keep getting is the following (with different providers, not only this one):

Uncaught Error: Can't resolve all parameters for LoginRedirectService: (App, ?, AlertController).

There seems to be a problem with resolving injections of my providers, even though they are all decorated with @Injectable.

one file

@Injectable()
export class LoginRedirectService {

    constructor(
        public app:App, 
        //another provider, needed within this one - this cannot be resolved
        public authService: AuthenticationService,
        public alert:AlertController
    )
//...
}

different file

@Injectable()
export class AuthenticationService {
    constructor(public dataService:DataService){
        //...
    }
}

//...

and so on.

I also have added all providers in the app.module.ts, in the order in which they have to be injected in:

//Ordered by dependencies, bottom is the most dependent on others
providers: [
    HttpModule,
    JsonpModule,
    RssService,
    EmergencyEmailService,
    InAppBrowserService,
    ExternalBrowser,
    AppLauncherService,
    LauncherPlaner,
    LauncherSkype,
    ConnectivityService,
    MockRemoteDataService,
    SoniaMirthRemoteDataService,
    DataService,
    AuthenticationService,
    LoginRedirectService,
    NewsStreamService,
    SoniaBootstrapService
]

My project structure looks like this:

  • src
    • app
      • app.module.ts
      • app.component.ts
    • assets
    • pages
    • providers
      • sub-folders
    • ...
  • package.json etc.

I have tried explicitly calling @Inject in the constructors of classes where they are needed, but no success either.

I am really out of ideas what to do and appreciate any help, thanks

Sonia
  • 41
  • 3
  • Is `AuthenticationService` or `DataService` dependent on `Http`? The `HttpModule` and `JsonpModule` should go in the `@NgModule.imports` not `providers`. If you don't already have it in the `imports`, and the service _is_ dependent on `Http`, that _would_ cause this error – Paul Samsotha Oct 25 '16 at 11:38
  • Thanks, I did remove them from there, but they were already added in imports, and it did not solve the issue. – Sonia Oct 25 '16 at 11:52
  • I had the same issue. In my case one Provider was importing the other though this doesn't seem to be the case here. Just my two cents in case someone else bumps here like I did :) – Marco Cardoso Mar 17 '17 at 10:01

1 Answers1

0

modules are not providers they reside in imports. Try above given by @peeskillet

anshuVersatile
  • 2,030
  • 1
  • 11
  • 18