gpt4 book ai didi

Angular2 No provider for AngularFireDatabase 注入(inject)错误

转载 作者:搜寻专家 更新时间:2023-10-30 22:03:41 26 4
gpt4 key购买 nike

我尝试关注 Angular2 setup steps严格来说,但我在控制台中遇到了一些错误:

错误错误:未捕获( promise ):错误:没有 AngularFireDatabase 的提供者!

sign-in.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { SignInComponent } from './sign-in.component';
import { AngularFireModule } from 'angularfire2';
import { fireBaseEnvironment } from '../environment';
import { AngularFireDatabaseModule } from 'angularfire2/database';
import { AngularFireAuthModule } from 'angularfire2/auth';

@NgModule({
imports: [
BrowserModule,
AngularFireModule.initializeApp(fireBaseEnvironment.firebase, 'my-app-name'), // imports firebase/app needed for everything
AngularFireDatabaseModule, // imports firebase/database, only needed for database features
AngularFireAuthModule, // imports firebase/auth, only needed for auth features
],
declarations: [ SignInComponent ],
bootstrap: [ SignInComponent ]
})
export class SignInModule {}

登录.component.ts

import {
Component,
OnInit
} from '@angular/core';
import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';

@Component({
selector: 'sign-in',
template: `
<p> Hi, this is the sign in bits jimmy</p>
<p>Click this to go to another place <a [routerLink]=" ['../detail'] " >Detail</a>
<ul>
<li class="text" *ngFor="let item of items | async">
{{item.$value}}
</li>
</ul>
`
})

export class SignInComponent {
public jimmy: 'testing';
public items: FirebaseListObservable<any[]>;
constructor(db: AngularFireDatabase) {
this.items = db.list('/items');
}
}

可爱的人有什么想法吗?

最佳答案

AngularFireModule.initializeApp(fireBaseEnvironment.firebase, 'my-app-name')

变量'FireBaseEnvoriment'包含firebase的数据,不需要

.firebase

,那么看起来像这样:

AngularFireModule.initializeApp(fireBaseEnvironment, 'my-app-name')

关于Angular2 No provider for AngularFireDatabase 注入(inject)错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43825856/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com