我想在我的網站上做一個評論部分。我已正確鏈接了所有文件,並從Firebase獲取數據正在運行。但是,評論僅在之後加載我要麼點擊某個內容,要麼在「添加評論」字段中輸入文本;它不會在頁面加載時立即顯示評論。有誰知道爲什麼?立即使用AngularJS從Firebase加載數據
相關代碼:。(放在我的控制器的頂部)
$scope.comments = {};
database.ref('comments').on('value', function(items) {
$scope.comments = items.val();
});
$scope.comment = function() {
database.ref('comments').push($scope.newComment);
$scope.newComment = "";
};
見http://stackoverflow.com/questions/35531161/採取長時間加載/ 35533455#35533455 –