我正在使用theres what i've logged click on this link数据获取这些对象,我想深入挖掘用户名和id,并将其绑定在一起。我该怎么做?
d {$$conf: Object, $id: "google:107950469269631469408", $priority: null}
$$conf
:
Object
$id
:
"google:107950469269631469408"
$priority
:
null
-KK87pj5tW9EL8hL9To7
:
Object
id
:
"google:107950469269631469408"
name
:
"muzi ngobe"
__proto__
:
Object我如何在对象中获取对象来实现这一点?
var ref = new Firebase("https://tasksbylima.firebaseio.com/");
$scope.profile = $firebaseObject(ref.child('users').child(authData.uid));
console.log($scope.profile);这是我的firebase Json树
{
"users" : {
"google:107950469269631469408" : {
"-KK87pj5tW9EL8hL9To7" : {
"id" : "google:107950469269631469408",
"name" : "muzi ngobe"
},
}
}
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div class="list card">
<div class="item item-divider">{{profile.name}}</div>
<div class="item item-body">
<form class="list">
<ion-checkbox>{{profile.name}}</ion-checkbox>
</form>
</div>
</div>发布于 2016-06-15 17:37:21
您可以通过访问object的第一个属性来解开answer对象:
var ref = new Firebase("https://tasksbylima.firebaseio.com/");
var response = $firebaseObject(ref.child('users').child(authData.uid));
var users = response[Object.keys(response)[0]];
var google = users[Object.keys(users)[0]];
var key = google[Object.keys(google)[0]];
console.log(key);https://stackoverflow.com/questions/37829836
复制相似问题