Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#3,683 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
冷清
技术栈
angular, typescript
领域
database

调研方向

首先,使用所示的 app.config.ts 和注入 AngularFireDatabase 的 Postingservice 复现注入错误。结合 standalone provider 设置阅读 compat 数据库设置,然后验证可以注入 AngularFireDatabase,并且 viewPosts() 能够读取 /posts,而不会出现 No provider found 错误。

由索引模型根据 Issue 内容生成。

描述

comp: compat needs: more info type: bug version: current (v17+)

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.

主要语言
TypeScript
星标
7.8k
派生
2.2k
平均合并
3 天 6 小时
30 天内合并 PR
5

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

angular/angularfire 的其他 Issue

查看 angular/angularfire 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。