angular 5 Error: Can't resolve all parameters for Service

Viewed 1667

I could use a little help.

Context I am making a angular 5 module for an authentication service.

How do I pass a POJO into a class as parameters?

See my answer below.

I need to use HttpClient inside this auth service

I am getting this error:

Error: Can't resolve all parameters for AuthService: ([object Object], ?).

[object Object] is angular 5 HttpClient

Can some one please explain why I am getting this error and how to resolve it?

@NgModule()

export class AuthtModule {
  static forRoot(params?: iParams) {
    return {
        ngModule: AuthModule,
        provides: [
            HttpClient,
            {
                provide: AuthService,
                useFactory: setupAuthService,
                deps: [ HttpClient, params ]
            }
        ],
        imports: [ HttpClientModule ],
        exports: [ AuthService ]            

    }
  }
}

Thanks in advance. Cheers

2 Answers

Try by importing import 'core-js/es7/reflect'; in polyfills.ts

Related