범주와 하위 범주가 있습니다.AngularFire 루프 비표준 데이터
데이터 구조는 blog 방송 같다 : [제어부]
$scope.findOneCategory = function (categoryId) {
angularFire(Categories.find(categoryId), $scope, 'category');
}
및 카테고리 서비스
을 :categories: {
-JF1RmYehtF3IoGN9xHG(categoryId): {
title: "Example",
subcategories: {
JF1RmYehtF3IoGN239GJ(subCategoryId): true
}
가 지금은 (단 하나의 카테고리에 대한) 데이터를 이런 식으로 검색하려면
find: function(categoryId) {
return FireRef.categories().child('/'+categoryId);
},
뷰 :
<div ng-init="findSubCategories()">
<li class="list-group-item" ng-repeat="subCategory in subCategories">{{ subCategory.name }}</li>
내가 현재이가 ... 방법을 알고
는하지만 지금은 범주의 하위 범주의 목록을 검색하고 해당 범위에 바인드해야하고 내가 해달라고
컨트롤러 :
$scope.findSubCategories = function() {
angularFire(Categories.findSubCategories($routeParams.categoryId), $scope, 'subCategories');
}
그리고 내가 뭔가 노력이 같은 서비스 보이지만 그것은 잘못과 하 어떻게 보일지 전혀 모르겠다 ... 누군가가 내가 기뻐할 수 있다면 도움이 될 것이다!
findSubCategories: function(categoryId) {
var subCategoriesIdsList = FireRef.categories().child('/'+categoryId).child('subcategories');
subCategoriesIdsList.on("child_added", function(snap) {
FireRef.subcategories().child("/"+snap.name()).once("value", function(snap) {
// Render the comment on the link page.
console.log(snap.val());(i see the object in console but have no idea how to bind it now with the view...:(
});
});
},
내가, API가 상당히 변경되었습니다 최신 AngularFire 버전 (현재 0.6)로 업그레이드하는 것이 좋습니다 것,
카테고리 및 하위 카테고리가 아니지만 게시물 및 사용자가 있으며 한 명의 사용자가 게시물 목록을 표시하려면이 방법이 올바른 해결책입니까? 많은 게시물과 많은 사용자가있을 수 있습니다. 이 작업을 수행하는 데 여러 가지 방법을 시도했지만 올바른 작업을 찾지 못하는 것 같습니다. –
하위 범주 목록이 실제로 길 경우 모든 항목을로드하는 것이 적절하지 않을 수 있습니다. 이 경우, 각 하위 카테고리에 대해 새로운 $ firebase 인스턴스를 생성하여 하나씩 가져올 수 있습니다 (아니면 일반 Firebase API를 사용하는 것일 수도 있습니다). – Anant