Angular v5とFirestoreにアップグレードしていますが、Firestoreデータからフィールドを抽出する際に多くの問題が発生しています。ファイアストアからデータをロードするにはどうすればよいのですか?
Angular 4がリリースされたときに問題があったため、AngleFire2を使用したくないです。
約10日前に私はスナップショットからデータを取得する方法を考え出しました。最後に、私はそれを行うためのコードを得た。残念ながら "doc.data()['languageName'];" "get"では動作しません。
querySnapshot.forEach(function (doc) {
let name = doc.data()['languageName'];
lang.push(name);
});
});
これで終日働いた後、私は助けを求めることにしました。私の最近の試みは以下の通りです。
firebase.auth().signInWithEmailAndPassword(email, password)
.then(staff => {
if (staff.emailVerified) {
this.result = this.db.collection("staff").doc(staff.uid).get()
.then(function(staffDb) { // staff.uid works
if (staffDb.exists) { // <-- Works to here
this.sid = staffDb.data.sid; // nor staff.sid
this.staff2memoryService.set(staffDb.data());
this.staff = this.db.collection("staff").
doc(this.sid).get()
.then(result => {
if (this.sid) {
this.staff2memoryService.set(result);
} else {
console.log('Not exist');
}
私がconsole.logを実行すると、私が望むすべてのデータがそこにありますが、私はそれを得ることができません。 firebaseのドキュメントは、console.logを使ってフィールドにアクセスする方法を示していますが、console.logがフィールドを自動的に抽出/マップするように見えるため、これは役に立ちません。