小编pec*_*ata的帖子

Firebase snapshot.val()未绑定到$ scope

我正在使用FireBase并尝试进行一些查询,结果是登录但在HTML中不可见$scope.

var shopRef = firebaseDataService.intro;

$scope.shops = [];

var taskRef = shopRef.orderByChild("cat").equalTo("Accomodation");


taskRef.on("value", function(snapshot) {
    var snapData = snapshot.val();
    console.log(snapData);
    $scope.shops.push(snapData);

});
Run Code Online (Sandbox Code Playgroud)

当我使用时$scope.$apply(),我设法将数据更新到商店,但它仍然没有将任何内容传递给我的指令.

    <search-card shops="shops">   </search-card>
    <p> Shops are {{shops}}</p>
Run Code Online (Sandbox Code Playgroud)

我用$ firebaseArray以某种方式工作了

  $scope.shops = $firebaseArray(taskRef);
Run Code Online (Sandbox Code Playgroud)

但是我仍然想知道我做错了什么,以及为什么它没有使用快照.

angularjs firebase angularfire firebase-realtime-database

2
推荐指数
1
解决办法
946
查看次数