compiler.js:2175 Uncaught Error: Can't resolve all parameters for AuthService: (?, ?, ?, ?).
at syntaxError (compiler.js:2175)
at CompileMetadataResolver._getDependenciesMetadata (compiler.js:20401)
at CompileMetadataResolver._getTypeMetadata (compiler.js:20296)
at CompileMetadataResolver._getInjectableTypeMetadata (compiler.js:20514)
at CompileMetadataResolver.getProviderMetadata (compiler.js:20523)
at compiler.js:20461
at Array.forEach (<anonymous>)
at CompileMetadataResolver._getProvidersMetadata (compiler.js:20421)
at CompileMetadataResolver.getNgModuleMetadata (compiler.js:20148)
at JitCompiler._loadModules (compiler.js:25824)
I am getting this error ^^ and I am confused. I am fairly new to web development. From the research I have done it is caused by a circular dependency. How can I fix this?
import { Injectable } from '@angular/core';
@Injectable()
export class AuthService {
authState: FirebaseAuthState = null;
public token: any;
constructor(private af: AngularFire, private db: AngularFireDatabase, private router: Router) {
af.auth.subscribe((auth) => { this.authState = auth; })
}
get authenticated(): boolean {
return this.authState !== null;
}
get currentUser(): any {
return this.authenticated ? this.authState.auth : null;
}
get currentUserId(): string {
return this.uthenticated ? this.authState.uid : '';
}
private socialSignIn(provider: number): firebase.Promise<FirebaseAuthState> {
return this.af.auth.login({provider, method: AuthMethods.Popup})
.then(() => this.updateUserData() )
.catch(error => console.log(error));
}
private updateUserData(): void {
let path = `users/${this.currentUserId}`;
let data = {
name: this.currentUser.displayName,
email: this.currentUser.email,
}
this.db.object(path).update(data)
.catch(error => console.log(error));
}
googleLogin(): firebase.Promise<FirebaseAuthState> {
return this.socialSignIn(AuthProviders.Google);
}
signOut(): void {
this.af.auth.logout();
this.router.navigate(['/'])
}
}
I have seen tons of posts about this but all of then use an injection or something. The other thing I have seen is people saying to use another service. How would I accomplish this?