angular / angular/angularfire

AngularFireModule from @angular/fire/compat not providing the database appropriately.

Aperta
#3,683 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
comp: compat needs: more info type: bug version: current (v17+)
Lingua principale
TypeScript
Stelle
7.8k
Fork
2.2k
Merge medio
22h 28m
PR unite (30g)
6

Descrizione

So I've been facing an issue for the past couple of days where whenever I try to use the **AngularFireDatabase** database to read or write to my Firebase database my console gives me the error:

Image

`No provider found for Database2. Source: Standalone[_Homecomponent].`

I'm currently running Angular 20.0 as AngularFire 21.0 is yet to be fully fleshed out.

My dummy service to test the data looks like this below:

Image

`import { Injectable } from '@angular/core';`
`import { AngularFireDatabase } from '@angular/fire/compat/database';`
`@Injectable({`
` providedIn: 'root'`
`})`
`export class Postingservice {`
`constructor(private afDb:AngularFireDatabase){}`
`viewPosts(){`
`return this.afDb.list("/posts").valueChanges();`
`}`
`}`

I've both tried instantiating the afDb in the constructor and using the inject() function and neither have worked to any avail.

Here also is my app.config.ts:

Image

`import { ApplicationConfig, provideBrowserGlobalErrorListeners, provideZoneChangeDetection } from '@angular/core';`
`import { provideRouter } from '@angular/router';`

`import { initializeApp, provideFirebaseApp } from '@angular/fire/app';`
`import { getDatabase, provideDatabase } from '@angular/fire/database';`
`import { routes } from './app.routes';`

`export const appConfig: ApplicationConfig = {`
` providers: [`
`provideBrowserGlobalErrorListeners(),`
`provideZoneChangeDetection({ eventCoalescing: true }),`
` provideRouter(routes), `
`provideFirebaseApp(() => `
` initializeApp({`
`// FIREBASE CONFIG DATA`
`})),`
`provideDatabase(() => getDatabase()),`
`]`
`};`

I've even provided the provideDatabase() function even as it's not necessary for the AngularFireDatabase as a provider and likewise it's been to no avail...

And my application is bootstrapping correctly as it runs just fine until I create an instance of the afDb database in a component where I then get the above stated error. Kindly help.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia riproducendo l’errore di injection con l’app.config.ts mostrato e il Postingservice che inietta AngularFireDatabase. Leggi la configurazione del database compat insieme alla configurazione del provider standalone, quindi verifica che AngularFireDatabase possa essere iniettato e che viewPosts() legga /posts senza l’errore No provider found.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
angular, typescript
Ambito
database
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Da chiarire
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.