Ionic and Firebase - InvalidPipeArgument: '[object Object]' for pipe 'AsyncPipe'

家住魔仙堡 提交于 2019-11-29 10:05:37
Hamed Baatour

I think you are using the new angularfire2 version which is version 5 in this case you should be doing the following:

import { Component } from '@angular/core';
import { AngularFireDatabase } from 'angularfire2/database';
import { Observable } from 'rxjs/Observable';

@Component({
  selector: 'page-shopping-list',
  templateUrl: 'shopping-list.html',
})
export class ShoppingListPage {
 shoppingListRef$: Observable<any[]>;
  constructor(database: AngularFireDatabase) {
    this.shoppingListRef$ = this.database.list('shopping-list').valueChanges();;
  }
}

as starting from version 5 database.list no longer returns an observable so you can't subscribe to it in the template using the async pipe. this is why you should chain the valueChanges() method which returns an Observable in this case.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!