angular / angular/angularfire

ERROR TypeError: Cannot read properties of undefined (reading 'firestore')

オープン
#3,553 コメント 3 件 リアクション 1 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
7.8k
フォーク
2.2k
平均マージ
22時間 28分
マージ済み PR(30日)
6

説明

### Version info

**Angular:*17*

**Firebase:*10*

**AngularFire:*18.0.1*

**Other (e.g. Ionic/Cordova, Node, browser, operating system):**Angular

### How to reproduce these conditions
I am trying to insert data in firebase but getting error

import { Injectable, inject } from '@angular/core';
import { Firestore, collection, collectionData, addDoc, CollectionReference, DocumentReference} from '@angular/fire/firestore';
import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http';

@Injectable({
providedIn: 'root'
})

export class UserService {
private ipApiUrl = 'https://ipapi.co/json/';
private firestore: Firestore = inject(Firestore);
usersCollection!: CollectionReference;
constructor(private http: HttpClient) {
}
async addUser() {
let user = await this.getIp

}
getIp() {
this.http.get(this.ipApiUrl).subscribe(ipDetails => {
addDoc(this.usersCollection, ipDetails).then((documentReference: DocumentReference) => {
console.log(documentReference,'popopopo')
})
})
}
}

### Debug output

** Errors in the JavaScript console **
ERROR TypeError: Cannot read properties of undefined (reading 'firestore')

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

UserService の例から始め、特に Firestore のインジェクション、usersCollection の宣言、addUser/getIp のエントリーポイントを確認してください。指定された Angular 17、Firebase 10、AngularFire 18.0.1 のバージョンでエラーを再現し、その後、undefined プロパティエラーなしでサービスが IP レスポンスを Firestore に追加できることを確認してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
angular, firebase, typescript
領域
databases
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。