【问题标题】:Runtime Error: Object(...) is not a function Ionic/Firebase/Angular运行时错误:Object(...) 不是函数 Ionic/Firebase/Angular
【发布时间】:2018-11-04 19:16:38
【问题描述】:

我正在创建一个 Ionic 应用程序,其中包含我想要显示的信息列表,我使用 Firebase 作为我的数据库(实时数据库)。

但我一直收到此错误:

Object(...) 不是函数

我不知道为什么,因为代码看起来不错(我检查了 angularfire2 git 以确保)。

代码如下:

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>

【问题讨论】:

    标签: angular typescript firebase firebase-realtime-database


    【解决方案1】:

    能否请您提供 rxjs 的版本。在大多数情况下,错误的版本可能会出现问题。我认为当前的 angularfire2 需要 rxjs 版本 6.0.0 或更高版本。完整的 javascript 堆栈也很有用。

    此外,如果您之前使用过另一个 rxjs 版本,现在尝试升级,请考虑迁移指南:Migration guide rxjs from 5 to 6

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-01
    • 2019-06-28
    • 1970-01-01
    • 2019-07-12
    • 1970-01-01
    • 2020-05-29
    相关资源
    最近更新 更多