【发布时间】:2016-06-15 21:29:59
【问题描述】:
theres what i've logged click on this link 好的,我现在使用 google 数据获取这些对象,我想深入了解用户名和 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>
【问题讨论】:
-
"loggin profile [object Object]" 发生这种情况是因为您在 console.log 中使用了字符串连接,因此为 $scope.profile 执行了 .toString 方法。要查看 $scope.profile 可以使用
debugger;或console.log($scope.profile); -
我在删除 concationation 后得到一个 NaN 并且仍然没有绑定到视图上
-
也去掉+号
-
好的,我已经对帖子进行了更新,我现在可以看到对象但它在其他对象中,现在我如何去获取其中的用户名和 ID 的数据。看看上面的更新
-
你能把它从复制粘贴格式化成普通格式吗?我可以看到名称字段,但用户名字段是什么?
标签: angularjs firebase firebase-realtime-database