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.

4

1 回答 1

0

在 HTML 上使用了多个错误的表达式,这将不起作用

  1. {{options.ulClass}}似乎是错误的,angularjs 不使用{{}}(插值)添加属性。它应该是ng-class="options.ulClass"
  2. ng-repeat有错误的表达

    ng-repeat="node in node[options.nodeChildren] 
            | filter:filterExpression:filterComparator(options.orderBy)"
    
于 2018-03-13T08:53:40.073 回答