【问题标题】:Firebase/Angular2 - load database table onceFirebase/Angular2 - 一次加载数据库表
【发布时间】:2018-02-24 09:13:09
【问题描述】:

我想调用我的数据库表一次,我认为这很简单,但我经常遇到错误!

TypeError: this.database.object(...).take 不是函数

这是我的.ts 文件:

import { AngularFireDatabase } from 'angularfire2/database';
import { FirebaseListObservable } from 'angularfire2/database';
@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  userData:any;
  locationRef:FirebaseListObservable<any>;

  constructor(
    public navCtrl: NavController,
    private storage: Storage,
    private database: AngularFireDatabase) {

      this.locationRef = this.database.object('location' , { preserveSnapshot: true }).take(1)
      console.log(this.locationRef)

  }

我认为这会起作用,但事实并非如此……我做错了什么?

我的 firebase 表如下所示:

|firebase-name
   - location
      - location-item-1
      - location-item-2
      etc..

我想获取一次表的快照并循环遍历它..

有什么想法吗?谢谢!

【问题讨论】:

    标签: javascript angular firebase firebase-realtime-database


    【解决方案1】:

    似乎问题是我不得不做this.database.database 这有点令人困惑......

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-16
      • 1970-01-01
      相关资源
      最近更新 更多