angular / angularfire

Angular + Firebase = ❤️
https://firebaseopensource.com/projects/angular/angularfire2
MIT License
7.7k stars 2.19k forks source link

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

Open Abhicurio opened 4 months ago

Abhicurio commented 4 months ago

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

JGSolutions commented 4 months ago

Getting some error but upgraded to Ang 18.1

JGSolutions commented 4 months ago

Has this been tested with the latest Angular version 18.1?

oarshad commented 4 months ago

This seems to be the fix for it: https://github.com/angular/angular-cli/issues/28038