0
我檢查了有關檢索和顯示數據的angularfire文檔,並且遇到了問題!我想我正在返回數據,但我只是沒有顯示它。這裏是一個鏈接到我的plnker:http://plnkr.co/edit/LZ24sRoSJjuCHQnEGzQz?p=preview從firebase中提取數據並在頁面上顯示
指數
<h1 ng-repeat="group in data.groups">{{group.name}}</h1>
JS
$scope.newGroup = {
name: '',
status: ''
};
$scope.addGroup = function(newGroup) {
groupsService.addGroup(newGroup);
$scope.newGroup = {
name: '',
status: ''
};
};
.factory('groupsService', ['$firebase', 'FIREBASE_URI',
function ($firebase, FIREBASE_URI) {
var ref = new Firebase(FIREBASE_URI);
var groups = $firebase(ref).$asArray();
var getGroups = function(){
return groups;
};
var addGroup = function (newGroup) {
console.log(newGroup)
groups.$add(newGroup);
};
return {
getGroups: getGroups,
addGroup: addGroup,
}
部分顯示組丟失。你的$ scope.data.groups是空的嗎? – webduvet 2014-12-03 16:03:57