运行时错误:Object(...)不是函数Ionic/Firebase/Angular [英] Runtime Error: Object(...) is not a function Ionic/Firebase/Angular
问题描述
我正在创建一个Ionic应用程序,其中有我要显示的信息列表,我使用Firebase作为数据库(实时数据库).
I'm creating an Ionic app where there is a list of information that I want to display, I'm using Firebase as my database (Realtime Database).
但是我一直收到此错误:
But I've been getting this error:
Object(...)不是函数
Object(...) is not a function
而且我不确定为什么自从代码看起来还不错(我检查了angularfire2 git来确定).
And I'm not sure why since the code seems fine (I checked angularfire2 git to make sure).
所以这是代码:
list.ts
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { AngularFireDatabase } from 'angularfire2/database';
@Component({
selector: 'page-list',
templateUrl: 'list.html'
})
export class ListPage {
informationslist:any;
constructor(public navCtrl: NavController, public navParams: NavParams,
private afDB: AngularFireDatabase) {
try{
this.informationslist = afDB.list('information', (ref) =>
ref.orderByChild('datetime')).valueChanges();
}catch(e){
console.log(e);
}
}
}
list.html
<ion-header>
<ion-navbar>
<button ion-button menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
<ion-title>List</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<ion-list>
<ion-item *ngFor="let i of informationslist | async">{{i.title}}</ion-item>
</ion-list>
</ion-content>
推荐答案
能否提供rxjs的版本.在大多数情况下,错误的版本可能会引起问题.我认为当前的angularfire2需要rxjs版本6.0.0或更高版本.完整的javascript堆栈也可能有用.
Can you please provide the version of rxjs. In most cases there could be a problem with the wrong version of it. I think current angularfire2 needs rxjs version 6.0.0 or greater. The full javascript stack could also be useful.
如果您以前使用过另一个rxjs版本,现在又尝试升级,请考虑以下迁移指南:
Also if you used another rxjs version before and now try to upgrade consider the migration guide for this: Migration guide rxjs from 5 to 6
这篇关于运行时错误:Object(...)不是函数Ionic/Firebase/Angular的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!