目前,我有一个firebase结构,列出了每个项目下包含项目的项目。目前,以下代码显示所有项目。现在当我点击一个项目时,它链接到项目页面。但是,我将如何仅显示与该项目相关的所有项目?
火灾基地结构有:
data
> project unique id's
> items
> item id's
> item title
app.controller("ItemDisplayController", function($scope, $firebaseArray) {
var ref = firebase.database().ref().child("data");
$scope.data = $firebaseArray(ref);
});

<li ng-repeat="project in projects">
<a href="#/items">
{{ project.projecttitle}}
</a>
</li>
&#13;
所以基本上如果项目一有两个项目,项目二有10个项目,当我点击项目一时,我会指向项目页面,并显示两个项目标题。
非常感谢任何协助。
答案 0 :(得分:0)
查看从$firebaseArray
服务返回的数据的结构:
app.controller("ItemDisplayController", function($scope, $firebaseArray) {
var ref = firebase.database().ref().child("data");
$scope.data = $firebaseArray(ref);
$scope.data.$loaded().then(function(data) {
console.log(data);
}).catch(function (error) {
console.error(error);
throw error;
);
});
$firebaseArray
服务将一个名为$loaded
的方法附加到返回的对象,该对象返回一个$q Service承诺,该承诺通过服务器中的数据解析完成或拒绝。
用它来诊断问题。