我曾試圖按照Angular2 setup steps爲信,但我有一點麻煩,在控制檯的錯誤:Angular2無提供AngularFireDatabase注射錯誤
錯誤錯誤:未捕獲的(在承諾):錯誤:沒有AngularFireDatabase的提供者!
登錄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 {}
登錄in.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');
}
}
任何想法可愛的人?
的文件沒有提到在這種情況下供應商。你的代碼中也有語法錯誤,順便說一句。 –
該文檔沒有提到,但我使用ionic2與angularfire2有同樣的錯誤,我解決了這個問題。 我不想放代碼,只是爲了瞭解錯誤是什麼。 – user7975062
@ALL這已經被回答了[這裏](http://stackoverflow.com/questions/43772474/no-provider-for-angularfiredatabase/43844301#43844301) –