Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No provider for AuthService! #8

Open
marcusaaronb opened this issue Mar 22, 2018 · 7 comments
Open

No provider for AuthService! #8

marcusaaronb opened this issue Mar 22, 2018 · 7 comments

Comments

@marcusaaronb
Copy link

core.js:1448 ERROR Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[SigninComponent -> AuthService]:
StaticInjectorError(Platform: core)[SigninComponent -> AuthService]:
NullInjectorError: No provider for AuthService!
Error: StaticInjectorError(AppModule)[SigninComponent -> AuthService]:
StaticInjectorError(Platform: core)[SigninComponent -> AuthService]:
NullInjectorError: No provider for AuthService!
at NullInjector.get (core.js:1002)
at resolveToken (core.js:1300)
at tryResolveToken (core.js:1242)
at StaticInjector.get (core.js:1110)
at resolveToken (core.js:1300)
at tryResolveToken (core.js:1242)
at StaticInjector.get (core.js:1110)
at resolveNgModuleDep (core.js:10854)
at NgModuleRef
.get (core.js:12087)
at resolveDep (core.js:12577)
at NullInjector.get (core.js:1002)
at resolveToken (core.js:1300)
at tryResolveToken (core.js:1242)
at StaticInjector.get (core.js:1110)
at resolveToken (core.js:1300)
at tryResolveToken (core.js:1242)
at StaticInjector.get (core.js:1110)
at resolveNgModuleDep (core.js:10854)
at NgModuleRef
.get (core.js:12087)
at resolveDep (core.js:12577)
at resolvePromise (zone.js:809)
at resolvePromise (zone.js:775)
at eval (zone.js:858)
at ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:4740)
at ZoneDelegate.invokeTask (zone.js:420)
at Zone.runTask (zone.js:188)
at drainMicroTaskQueue (zone.js:595)
at

@praveen-vasudhaika
Copy link

praveen-vasudhaika commented Apr 2, 2018

@marcusaaronb
I was also facing the same issue
screenshot from 2018-04-02 15-11-46

later, I realized that I missed 'SocialLoginModule' to include in my main module. This might be the case for you as well.

@as88425
Copy link

as88425 commented Apr 6, 2018

@praveen-vasudhaika I am also facing the same issue. How did you get to resolve? Could you please brief?
Thanks!

@praveen-vasudhaika
Copy link

praveen-vasudhaika commented Apr 6, 2018

@as88425
I had missed to include > SocialLoginModule in imports under NgModule decorator on my main module:

@NgModule({
  imports: [
    ...
    SocialLoginModule
  ],
  declarations: [...],
  providers : [
    {
      provide: AuthServiceConfig,
      useFactory: getAuthServiceConfigs
    }
  ]
})

hope this helps!!

@as88425
Copy link

as88425 commented Apr 6, 2018

@praveen-vasudhaika as per your steps I also did in my signin.component.ts

@Component({
  selector: 'app-signin',
  templateUrl: './signin.component.html',
  styleUrls: ['./signin.component.css'],
  providers: [SocialLoginModule, AuthService]
})

it's workin for me now

@sk-sethi
Copy link

Through normal angular build its working fine but when i used Webpack build , its throwing exception "Can't resolve all parameters in AppComponent (?) e.g AuthService"

Do you have any solution for this :)

import { Component, OnInit } from '@angular/core'
import { SocialLoginModule } from 'angularx-social-login'
import { AuthService } from "angularx-social-login";
import { GoogleLoginProvider } from "angularx-social-login";
import { SocialUser } from "angularx-social-login";

@component({
selector: 'app-easy',
templateUrl: '../../Scripts/Home/Components/appComponent.html',
providers: [SocialLoginModule,AuthService]
})
export class AppComponent implements OnInit
{
myName: string
user: SocialUser
loggedIn:boolean

constructor(private authService: AuthService) {
    this.myName = "sujit"
}

getName = ()=> {
    return this.myName
}
signInWithGoogle(): void {
    this.authService.signIn(GoogleLoginProvider.PROVIDER_ID);
}
signOut(): void {
    this.authService.signOut();
}
ngOnInit() {
    this.authService.authState.subscribe((user) => {
        this.user = user;
        this.loggedIn = (user != null);
    });
}

@MahaprojectIngen
Copy link

thanks for the hint you have provided @praveen-vasudhaika ,it save my day

@afzal202
Copy link

core.js:6456 ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(LoginPageModule)[AuthService -> AuthService -> AuthService -> HttpService -> HttpClient -> HttpClient -> HttpClient]:
NullInjectorError: No provider for HttpClient!
NullInjectorError: R3InjectorError(LoginPageModule)[AuthService -> AuthService -> AuthService -> HttpService -> HttpClient -> HttpClient -> HttpClient]:
NullInjectorError: No provider for HttpClient!
at NullInjector.get (core.js:11081)
at R3Injector.get (core.js:11247)
at R3Injector.get (core.js:11247)
at R3Injector.get (core.js:11247)
at injectInjectorOnly (core.js:4728)
at ɵɵinject (core.js:4732)
at Object.HttpService_Factory [as factory] (ɵfac.js? [sm]:1)
at R3Injector.hydrate (core.js:11416)
at R3Injector.get (core.js:11236)
at injectInjectorOnly (core.js:4728)
at resolvePromise (zone.js:1255)
at resolvePromise (zone.js:1209)
at zone.js:1321
at ZoneDelegate.invokeTask (zone.js:434)
at Object.onInvokeTask (core.js:28661)
at ZoneDelegate.invokeTask (zone.js:433)
at Zone.runTask (zone.js:205)
at drainMicroTaskQueue (zone.js:620)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants