简体   繁体   English

无法解析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], ?) . 错误读取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",

I have been getting the same error. 我一直得到同样的错误。 It is because you have AngularFirestore listed as a service provider which it is not. 这是因为您将AngularFirestore列为服务提供商,而不是。 But once removed as a provider I get another error : 但是一旦作为提供者删除,我会得到另一个错误:

Error: No provider for AngularFirestore! at injectionError at noProviderError

To fix this error you have to import AngularFirestoreModule into your app.module.ts 要修复此错误,您必须将AngularFirestoreModule导入app.module.ts

Like the following: 如下:

import { AngularFirestoreModule } from 'angularfire2/firestore';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    .....
    AngularFireModule.initializeApp(firebaseConfig),
    AngularFirestoreModule <---
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Please remove the arrow behind AngularFirestoreModule it is there just to make it clear where it is supposed to be placed. 请删除AngularFirestoreModule后面的箭头,只是为了清楚它应该放在哪里。

you have to import AngularFirestoreModule into your app.module.ts 你必须将AngularFirestoreModule导入你的app.module.ts

In imports and providers. 在进口和提供商。

 imports: [
    BrowserModule,
    .....
    AngularFireModule.initializeApp(firebaseConfig),
    AngularFirestoreModule
  ],

providers: [AngularFirestoreModule],
.....

After check imports, issues end. 检查导入后,问题结束。 My imports app.module in below: 我的导入app.module如下:

  imports: [
    BrowserModule,
    AngularFireModule.initializeApp(environment.firebase),
    AngularFirestoreModule,
    AngularFirestoreModule.enablePersistence(),
    AngularFireAuthModule, 
    NgbModule.forRoot(),
    AppRoutingModule,
    HttpModule,
    HttpClientModule,
  ],

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法解析 AngularFirestore (PROD Build) 的所有参数 - Can't resolve all parameters for AngularFirestore (PROD Build) 无法解析...的所有参数([对象对象],[对象对象],?,?) - Can't resolve all parameters for … ([object Object],[object Object], ?, ?) 无法解析HttpXsrfCookieExtractor的所有参数:(?,[对象对象],[对象对象]) - Can't resolve all parameters for HttpXsrfCookieExtractor: (?, [object Object], [object Object]) 无法解析组件的所有参数:(?, [object Object], [object Object]) - Can't resolve all parameters for Component: (?, [object Object], [object Object]) 无法解析AuthenticationService的所有参数:([object Object],?,[object Object]) - Can't resolve all parameters for AuthenticationService: ([object Object], ?, [object Object]) 无法解析PlatformService的所有参数:([对象对象],?,[对象对象]) - Can't resolve all parameters for PlatformService: ([object Object], ?, [object Object]) 无法解析 ToastrService 的所有参数:(?, [object Object], [object Object], [object Object], [object Object]) - Can't resolve all parameters for ToastrService: (?, [object Object], [object Object], [object Object], [object Object]) Angular 2无法解析[object Object]的所有参数 - Angular 2 Can't resolve all parameters for [object Object] 未捕获的错误:无法解析“ComponentName”的所有参数:([object Object],?) - Uncaught Error: Can't resolve all parameters for 'ComponentName': ([object Object], ?) 无法解析LoginPage的所有参数:([object Object] ,?) - Can't resolve all parameters for LoginPage: ([object Object], ?)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM