list - Dynamic multi-level repeats with AngularJS -


i having problem in cannot find answer anywhere on internet. trying dynamically create category list in angularjs don´t know on forehand how many levels need. values fetched database, parentid, , each element may have 1 or more children.

i have used ng-repeat before create two-level lists, not know how add more levels without nesting many repeats need on forehand. know how in php generate data, not wish accomplish.

i might need use directives or sort, need point me in right direction.

there kind of solution in plunk: http://plnkr.co/edit/nbdgqkoy2qvmqeykqqty?p=preview think dirty fix, , searching better one.

thank tips or hints.

kind regards, kjetil.

you create directive decides how many levels there , build/$compile template in link function. more info on how create directive here.

app.directive('categorylist', function($compile) {   return {     link: function(scope, elm, attr) {       scope.$watch('somethingthatshowyoushouldrebuild', function() {         // log figures aout how many levels (a recursive function probably)         // build html template nested ng-repeat's         var template = // ...         elm.html(template);         $compile(elm)(scope);       });     }   } }); 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -