Multi-level Item list + json


#1

Hi! I’m new here and please,i need a little help to build a multi-level item list from Json!

I need something like this:
Item1
SubItem1
Detail
SubItem2
Detail
SubItem1
Detail
Item2
SubItem1
Detail

.controller(‘ItemListCtrl’, function($scope, $rootScope){
$rootScope.itemlist = [
{title: “name”, id:001,
sublist: [
{subtitle: “subname1”, idsub:001,
detail: [“detail1”, “detail2”, “detail3”]
},
{subtitle: “subname2”, idsub:002,
detail: [“detail1”, “detail2”]
}]
},
{title: “name2”, id:002,
sublist: [
{subtitle: “subname”, idsub:001,
detail: [“detail1”, “detail2”, “detail3”]
}]
}];
})

The title will be my Item, and subtitle my subitem with details. My ItemListCtrl is ok.

.controller(‘ItemList2Ctrl’, function($scope, $stateParams, $rootScope){
var id = $stateParams.itemId;

for(var i = 0; i < $rootScope.itemlist.length; i++) {   
    var n = 0
    do {            
        $scope.idsub = $rootScope.itemlist[i].sublist[n].idsub;
        $scope.subtitle = $rootScope.itemlist[i].sublist[n].subtitle; 
        n++;
    }
    while (n < $rootScope.itemlist[i].sublist.length);
}

})

thats my subitem controler, I cannot display my subtitle. Whats wrong?
Could you help me?

Thank you!