angular / angular/angularfire

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

Ouverte
#3,683 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
comp: compat needs: more info type: bug version: current (v17+)
Langage dominant
TypeScript
Étoiles
7.8k
Forks
2.2k
Merge moyen
22 h 28 min
PR mergées (30 j)
6

Description

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.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par reproduire l’erreur d’injection avec le app.config.ts présenté et le Postingservice qui injecte AngularFireDatabase. Lisez la configuration de la base de données compat parallèlement à la configuration du provider standalone, puis vérifiez que AngularFireDatabase peut être injecté et que viewPosts() lit /posts sans l’erreur No provider found.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
angular, typescript
Domaine
database
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Calme
Clarté
À clarifier
Accessibilité débutants
42/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.