对于其他有这个问题的人,
NgZone
这就是我的答案。
我进口的:
import { NgZone } from '@angular/core';
添加到构造函数中:
public zone: NgZone,
然后把它包装在我的firebase代码中:
this.zone = new NgZone({});
if(fromClick) { this.subscription.off(); }
this.postFeed = new Array();
this.subscription = this.database.database.ref('/posts/'+this.locationId)
.orderByChild('score')
.limitToLast(10);
this.subscription.on('child_added', (snapshot) => {
this.zone.run(() => {
this.postFeed.push(snapshot.val())
}):
});
这对我来说非常有效。我找不到真正的
原因
但我刚刚把
恩格兰
围绕我所有的firebase函数编写代码,它的工作方式和以前一样。如果其他人有更多的信息那就太好了。