0

I have a question regarding angular-tree-control usage, why {{node.label}} in below code is not binding successfully... For example, i have a custom node template like below:

<ul {{options.ulClass}}>
     <li ng-repeat="node in node.{{options.nodeChildren}} | filter:filterExpression:filterComparator {{options.orderBy}}"
         ng-class="headClass(node)"
         {{options.liClass}}
         set-node-to-data>
          {{node.label}}
         <i class="tree-branch-head" ng-class="iBranchClass()" ng-click="selectNodeHead(node)"></i>
         <i class="tree-leaf-head {{options.iLeafClass}}"></i>
         <i>
             <b>
                 <div class="tree-label {{options.labelClass}}" ng-class="[selectedClass(), unselectableClass()]"
                      ng-click="selectNodeLabel(node)" tree-transclude></div>
             </b>
         </i>
         <treeitem ng-show="nodeExpanded()"></treeitem>
     </li>
 </ul>

Here the {{node.label}} binding is not working, how can i make it binding.

I have created a simple plnkr to make it clear:

https://plnkr.co/edit/WdnJhmuZtibU0AyiDU3s?p=preview

Question:

In plnkr 'scripts.js' line 8, why {{node.label}} is not binding well.

I have used angular-tree-control a lot in our project, in some scenarios we want have some dynamic percentage value in front of the node icon. That's why i need the binding here.

huan feng
  • 7,307
  • 2
  • 32
  • 56
  • 1.Using same node object 2.node in node.{{options.nodeChildren}} , you are looping on $scope.node , is it have data ? – RITESH ARORA Mar 13 '18 at 08:53

1 Answers1

0

There are multiple wrong expression have been used on HTML, that will not work

  1. {{options.ulClass}} is seems to be wrong, angularjs doesn't add attribute using {{}}(interpolation). It should be ng-class="options.ulClass"
  2. Also ng-repeat has wrong expression

    ng-repeat="node in node[options.nodeChildren] 
            | filter:filterExpression:filterComparator(options.orderBy)"
    
Pankaj Parkar
  • 134,766
  • 23
  • 234
  • 299
  • Thanks for answer! Have you ever had a chance to look at the plnkr? Can you help to make it work, the 2 issues you mentioned seems not correct, this template is a String, and it will do interpolation and compilation in treeControl directive. Please help to see the plnkr for the whole code – huan feng Mar 14 '18 at 03:34