2016-08-22 74 views
0

的數據,我不知道如何訪問這是我從火力地堡接收到的數據,這裏是對象:angularfire負荷火力

0:Object 
$$hashKey : "object:4" 
$id : "-KPoOlGpoArhMjgPLms_" 
$priority : null 
$value : "{"name":"jone","phone":null,"company":null,"email":null,"workPhone":null,"address":null}" 
__proto__ : Object 
1 : Object 
$$hashKey : "object:5" 
$id : "-KPoOvSLgVFxa0ca7qaL" 
$priority : null 
$value : "{"name":"jone","email":"[email protected]","phone":null,"company":null,"workPhone":null,"address":null}" 
__proto__ : Object 

我該如何找回我需要,如信息:$ ID和$值的字段我需要

這裏是我的控制器:

var db = fireBaseApp.instance.database().ref('contacts'); 
$scope.contacts = $firebaseArray(db); 
$scope.contacts.$loaded().then(function (data) { 
    $scope.cont = data; 
    console.log($scope.cont); 
}); 

,所以我需要獲取數據

回答

1

方法一:

var users = null; 
function allContacts() { 
users = $firebaseArray(db.child('contacts')); 
} 
return users; 
} 

或使用,這也

function allContacts() { 
var ref = firebase.database().ref('/contacts') 
var obj = $firebaseObject(ref); 
obj.$loaded().then(function() { 
    angular.forEach(obj, function(value, key) { 
    console.log(value, key); 
    }); 
}); 
} 
+0

感謝,它的工作原理,但是當我添加一個新的記錄火力它不更新,我已經使用了第二個方法 – Mikail