Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#3,553 3 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
angular, firebase, typescript
Lĩnh vực
databases

Hướng nghiên cứu

Bắt đầu với ví dụ UserService, đặc biệt là phần injection của Firestore, khai báo usersCollection và các entry point addUser/getIp. Tái hiện lỗi với các phiên bản Angular 17, Firebase 10 và AngularFire 18.0.1 đã nêu, sau đó xác minh rằng service có thể thêm phản hồi IP vào Firestore mà không gặp lỗi thuộc tính undefined.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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')

Ngôn ngữ chính
TypeScript
Star
7.8k
Fork
2.2k
Merge trung bình
3 ngày 6 giờ
Pull request đã merge (30 ngày)
5

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của angular/angularfire

Tất cả issue của angular/angularfire

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.