问题描述
我有,我可以访问所有的元素从我的范围,因为数据模型的到来,我也可以看到在Chrome控制台的范围元素,一个奇怪的问题,但是当我尝试使用NG-repeat语句中的模型它不工作,它只是通过 vm.menu.items 不循环。下面是我简单的code:
I'm having a weird issue, I can access all the elements coming from my scope as data model, also I can see the scope elements in the Chrome console, but when I try using the model within a ng-repeat statement it does not work, it just does not loop through the vm.menu.items. Below is my simple code:
<body ng-controller="mainController">
<div ng-controller="app.views.layout.header as vm">
<p>{{vm.currentMenuName}} {{vm.menu.items[0].displayName}} {{vm.menu.items[1].displayName}}</p> **<<----- IT works!**
<ul>
<li ng-repeat="menuItem in vm.menu.items">
<span>Not working! </span>{{menuItem.displayName}}
</li>
</ul>
</div>
</body>
我还是pretty新的角度,使点我到正确的方向任何帮助将大大AP preciated。
I'm still pretty new to angular, so any help that point me into the right direction will be greatly appreciated.
推荐答案
我删除了虚拟机。在你的HTML,一切按预期工作。
I removed the 'vm.' in your html and everything works as expected
<body ng-controller="mainController">
<div ng-controller="app.views.layout.header as vm">
<p>{{currentMenuName}} {{menu.items[0].displayName}} {{menu.items[1].displayName}}</p>
<ul>
<li ng-repeat="menuItem in menu.items">
<span>Not working! </span>{{menuItem.displayName}}
</li>
</ul>
</div>
或者你能给我们'这'在你的控制器,而不是$范围(见
Or you can us 'this' in your controller instead of $scope (see http://plnkr.co/edit/1BtC8p1ViqKXSbCWE3Kj?p=preview
这篇关于AngularJS伍重复功能未正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!