无法解析AngularFirestore的所有参数:([object Object],?) [英] Can't resolve all parameters for AngularFirestore: ([object Object], ?)
问题描述
一段时间以来,我一直在尝试解决此错误.错误显示为Can't resolve all parameters for AngularFirestore: ([object Object], ?)
.有没有其他人遇到这个问题,以及您如何解决该问题.我已经阅读了文档,但无法深入了解此问题.
I've been trying to troubleshoot this error for a while. The error reads Can't resolve all parameters for AngularFirestore: ([object Object], ?)
. Has anyone else had this issue, and how were you able to resolve the issue. I've read the docs, and I can't get to the bottom of this issue.
import { Component } from '@angular/core';
import { AngularFirestore } from 'angularfire2/firestore';
import { AngularFireDatabase } from 'angularfire2/database';
import { Observable } from 'rxjs/Observable';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
providers: [AngularFirestore, AngularFireDatabase]
})
export class AppComponent {
items: Observable<any[]>;
constructor(db: AngularFirestore, adb: AngularFireDatabase) {
this.items = db.collection('0').valueChanges();
console.log(this.items)
}
}
package.json
package.json
"angularfire2": "^5.0.0-rc.3",
"firebase": "^4.6.0",
推荐答案
我遇到了同样的错误.这是因为您将AngularFirestore列为服务提供者而未列出.但是一旦删除为提供程序,我会遇到另一个错误:
I have been getting the same error. It is because you have AngularFirestore listed as a service provider which it is not. But once removed as a provider I get another error :
Error: No provider for AngularFirestore!
at injectionError
at noProviderError
Error: No provider for AngularFirestore!
at injectionError
at noProviderError
要解决此错误,您必须将AngularFirestoreModule
导入到app.module.ts
To fix this error you have to import AngularFirestoreModule
into your app.module.ts
类似以下内容:
import { AngularFirestoreModule } from 'angularfire2/firestore';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
.....
AngularFireModule.initializeApp(firebaseConfig),
AngularFirestoreModule <---
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
请删除AngularFirestoreModule后面的箭头,该箭头只是为了弄清楚应将其放置在何处.
Please remove the arrow behind AngularFirestoreModule it is there just to make it clear where it is supposed to be placed.
这篇关于无法解析AngularFirestore的所有参数:([object Object],?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!