javascript - How to do recursive directive with $templateCache? -


i trying use angular.treeview display tree structure, , works fine. however, causes infinite loop when use $templatecache make more maintainable. looks using string store template removes outermost loop in recursive calls not happening template retrieved $templatecache. see problem after commenting out second line (line #88 in angular.treeview.js) in example @ http://plnkr.co/edit/khq7bmpryedk6b1pvldy?p=preview.

$log.log('cache:' + templatecache.get('treenode.html')); //template = templatecache.get('treenode.html $log.log('string:' + template);                     //rendering template.                     element.html('').append( $compile( template )( scope ) ); 

the other question if can $templatecache work how replace variables in template before it's compiled? i'd replace variables treemodel , nodechildren in template make code more flexible.

got working naming controller's $scope variable same recursive call's. in other words, change $scope.rolelist $scope.node.children solved infinite loop problem.

//template refrence node.children <li data-ng-repeat="node in node.children">  //assign tree nodes $scope.node.children $scope.node = {}; $scope.node.children = this.rolelist1; 

since have moved using controlleras syntax, created example @ http://plnkr.co/edit/ua63ilaaqsrtgigfbmaq?p=preview fix, , mix of using $scope , controlleras variables. fix utilize side-effect of referencing $scope variables without qualifying $scope., can use same name refer $scope variables local variables inside recursive loop.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -