You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi everybody, how are you? I write for a query. I want to authenticate user using AngularFireAuth with google and there seems to be an error in the dependency injection. I looked for various alternatives, even adding AngularFireAuthModule to AppModule.ts, but couldn't get it to work. The component is not displayed (it is simply a button) and I get this error in the console:
ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(AppModule)[AngularFireAuth -> AngularFireAuth -> AngularFireAuth]:
NullInjectorError: No provider for AngularFireAuth!
NullInjectorError: R3InjectorError(AppModule)[AngularFireAuth -> AngularFireAuth -> AngularFireAuth]:
NullInjectorError: No provider for AngularFireAuth!
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 NgModuleRef$1.get (core.js:25341)
at Object.get (core.js:25055)
at lookupTokenUsingModuleInjector (core.js:3342)
at getOrCreateInjectable (core.js:3454)
at Module.ɵɵdirectiveInject (core.js:14714)
at NodeInjectorFactory.LoginComponent_Factory [as factory] (login.component.ts:13)
at resolvePromise (zone.js:1213)
at resolvePromise (zone.js:1167)
at zone.js:1279
at ZoneDelegate.invokeTask (zone.js:406)
at Object.onInvokeTask (core.js:28661)
at ZoneDelegate.invokeTask (zone.js:405)
at Zone.runTask (zone.js:178)
at drainMicroTaskQueue (zone.js:582)
at ZoneTask.invokeTask [as invoke] (zone.js:491)
at invokeTask (zone.js:1600)
my component ts file is:
import { Component, OnInit } from '@angular/core';
import * as firebase from 'firebase/app';
import {AngularFireAuth} from 'angularfire2/auth' @component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit {
constructor(private afAuth: AngularFireAuth) {}
login() {
this.afAuth.auth.signInWithRedirect(new firebase.auth.GoogleAuthProvider());
}
}
and my component html file is:
<button (click)="login()" mat-raised-button color="accent">Login with google
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi everybody, how are you? I write for a query. I want to authenticate user using AngularFireAuth with google and there seems to be an error in the dependency injection. I looked for various alternatives, even adding AngularFireAuthModule to AppModule.ts, but couldn't get it to work. The component is not displayed (it is simply a button) and I get this error in the console:
ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(AppModule)[AngularFireAuth -> AngularFireAuth -> AngularFireAuth]:
NullInjectorError: No provider for AngularFireAuth!
NullInjectorError: R3InjectorError(AppModule)[AngularFireAuth -> AngularFireAuth -> AngularFireAuth]:
NullInjectorError: No provider for AngularFireAuth!
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 NgModuleRef$1.get (core.js:25341)
at Object.get (core.js:25055)
at lookupTokenUsingModuleInjector (core.js:3342)
at getOrCreateInjectable (core.js:3454)
at Module.ɵɵdirectiveInject (core.js:14714)
at NodeInjectorFactory.LoginComponent_Factory [as factory] (login.component.ts:13)
at resolvePromise (zone.js:1213)
at resolvePromise (zone.js:1167)
at zone.js:1279
at ZoneDelegate.invokeTask (zone.js:406)
at Object.onInvokeTask (core.js:28661)
at ZoneDelegate.invokeTask (zone.js:405)
at Zone.runTask (zone.js:178)
at drainMicroTaskQueue (zone.js:582)
at ZoneTask.invokeTask [as invoke] (zone.js:491)
at invokeTask (zone.js:1600)
my component ts file is:
import { Component, OnInit } from '@angular/core';
import * as firebase from 'firebase/app';
import {AngularFireAuth} from 'angularfire2/auth'
@component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit {
constructor(private afAuth: AngularFireAuth) {}
login() {
this.afAuth.auth.signInWithRedirect(new firebase.auth.GoogleAuthProvider());
}
}
and my component html file is:
<button (click)="login()" mat-raised-button color="accent">Login with google
Beta Was this translation helpful? Give feedback.
All reactions