ng-repeat绑定元素数组多次

时间:2014-11-06 20:31:10

标签: angularjs kendo-ui

我有3个元素的字典,当我尝试使用ng-repeat进行绑定时,每个字典元素都会被绑定3次。当元素数量增加到4时,每个字典元素将被绑定4次。

<ul>
                        <li ng-repeat="(m, v) in vm.test track by $index">
                            <span>{{m}}:{{v}}</span>
                        </li>
 </ul>

vm.test包含 - {a:1,b:2,c:3}

任何人都可以帮我找到这里的问题吗? 我在角度指令中使用它。

问题更新**

当我得到html内容时,我看到ng-repeat存在两次:

<ul>
                   <!-- ngRepeat: (m, v) in vm.test track by $index --><li ng-repeat="(m, v) in vm.test track by $index" class="ng-scope">
                       <span class="ng-binding">a:1</span>
                   </li><!-- end ngRepeat: (m, v) in vm.test track by $index --><li ng-repeat="(m, v) in vm.test track by $index" class="ng-scope">
                       <span class="ng-binding">b:2</span>
                   </li><!-- end ngRepeat: (m, v) in vm.test track by $index --><li ng-repeat="(m, v) in vm.test track by $index" class="ng-scope">
                       <span class="ng-binding">c:3</span>
                   </li><!-- end ngRepeat: (m, v) in vm.test track by $index -->
               </ul>

两次添加ng-repeat会是什么情况?

0 个答案:

没有答案