不从 Angularfire 更新视图

Not updating view from Angularfire

让我们尽量简化这个过程。尽管 Firebase 正在发生变化,但我的观点并未更新。我曾尝试在这里和那里使用回调函数,但没有成功,而且这里似乎不需要它们,但我的视图直到页面刷新后才更新。每次单击按钮时,我都试图实现一个计数器。

查看

//The selected is just because I needed to select the key to show the correct
//values in the view
<div class="row"><div class="onehundred">{{hc.selected.counter}}</div>
<span class="onehundreddonuts"> donuts</span></div>

控制器

function incrementCounter() {
//I have tried wrapping this in a .then(function(){}) callback function based 
//on the self.player.$loaded() but this doesn't fix anything, so I took it out
//for simplicity. If I console.log my self.player = homeService.player array
//it prints it out correctly anyway.

homeService.incrementCounter();
}

服务

function incrementCounter() {
self.counter ++;
self.update();

}
function update() {
self.player.$save(key);
}

我发现这在类似情况下会有所帮助:

$timeout(function() {
    $scope.$apply();
});