Having recently started working with Angular, I am facing an issue while trying to implement Google login. Whenever I click on the button created for the purpose, it does not redirect me to the Google login page and instead shows an error. I am unsure about what is causing this error, so here is my code:
import { Component } from '@angular/core';
import { AngularFireAuth} from 'angularfire2/auth';
import * as firebase from 'firebase';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css']
})
export class LoginComponent {
constructor(private afAuth: AngularFireAuth ){}
loginbtn() {
return this.afAuth.auth.signInWithRedirect(new firebase.auth.GoogleAuthProvider());
}
}
module:
import { AngularFireAuth} from 'angularfire2/auth';
providers: [AngularFireAuth]
Error Message :
core.js:1449 ERROR Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[LoginComponent -> AngularFireAuth]:
StaticInjectorError(Platform: core)[LoginComponent -> AngularFireAuth]:
NullInjectorError: No provider for AngularFireAuth!
Error: StaticInjectorError(AppModule)[LoginComponent -> AngularFireAuth]:
StaticInjectorError(Platform: core)[LoginComponent -> AngularFireAuth]:
NullInjectorError: No provider for AngularFireAuth!
at _NullInjector.get (core.js:1003)
at resolveToken (core.js:1301)
at tryResolveToken (core.js:1243)
at StaticInjector.get (core.js:1111)
at resolveToken (core.js:1301)
...