【问题标题】:Endless loop in angularfire2 subscriptionangularfire2订阅中的无限循环
【发布时间】:2017-03-30 14:22:18
【问题描述】:

我正在获取数据并将数据添加到订阅中的同一节点。如何避免死循环?

this.af.database.list('objects/').subscribe(x=>{   / the subscription is only needed once
  this.af.database.list('objects/').push({newobject: ''};
};

【问题讨论】:

    标签: angular firebase angularfire2


    【解决方案1】:

    如果我错了,就向我开枪,或者不要,但我相信你可以使用first() 方法:

    this.af.database.list('objects/').first().subscribe(x=>{ 
      this.af.database.list('objects/').push({newobject: ''};
    };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-10
      • 2017-03-11
      • 2018-09-02
      • 1970-01-01
      • 1970-01-01
      • 2017-04-05
      • 1970-01-01
      • 2019-03-06
      相关资源
      最近更新 更多