@sprw

Are you sure you want to delete the question?

Leaving a resolved question undeleted may help others!

Angularでfirebaseのauthメソッドが使用できない

Tuyano SYODA氏のAngular超入門のP375でgoogleアカウントで認証してログインする機能を作る部分があります。
以下のtsファイルで各authの行で

Property 'auth' does not exist on type 'AngularFireAuth'.

というエラーが出ます。

import { Component, OnInit } from '@angular/core';
import { AngularFirestore } from '@angular/fire/firestore';
import * as firebase from "firebase";
import { AngularFireAuth } from '@angular/fire/auth';
import { auth } from 'firebase/app';

@Component({
selector: 'app-fire',
templateUrl: './fire.component.html',
styleUrls: ['./fire.component.css']
})
export class FireComponent implements OnInit {
message:string = 'people data.';
data:any;

constructor(private db:AngularFirestore, public afAuth: AngularFireAuth) { }

ngOnInit() {
this.access();
}

access() {
this.db.collection('people')
.valueChanges()
.subscribe(value=>{
this.data = value;
},
error=>{
this.message = "(can't get data...)";
this.data = null;
});
}

login(){
let provider = new firebase.auth.GoogleAuthProvider();
this.afAuth.auth.signInWithRedirect(provider)
.then((result)=>{
this.access();
});
}

logout() {
this.afAuth.auth.signOut();
this.access();
}

get currentUser() {
return this.afAuth.auth != null ?
this.afAuth.auth.currentUser != null?
this.afAuth.auth.currentUser.displayName :
'(not logined.)' :
'(not logined.)';
}
}
import文のauthが読み取られず、、、
もしわかる方がいたら教えていただけると嬉しいです。
よろしくお願いします。

0 likes

No Answers yet.

Your answer might help someone💌