[英]AngularJS controller, required by directive, can't be found
I have an error for each "message" 每个“消息”都有错误
Error: [$compile:ctreq] Controller 'accordion', required by directive 'accordionGroup', can't be found!
with my code in html 用我的HTML代码
<h2 data-ng-if="!!messageData.messages.length">Messages</h2>
<accordion close-others="true">
<accordion-group data-ng-repeat="m in messageData.messages">
<accordion-heading>
<span>{{ m.head }}</span>
<span class="pull-right">{{ m.created | date:'d-MMM-yyyy HH:mm' }}</span>
</accordion-heading>
<p>{{ m.body }}</p>
</accordion-group>
</accordion>
but messages are views with no problems 但是消息是没有问题的视图
UPD 1: i tried to debug angular.js and function getControllers return different values for "empty accordion-group" and "accordion-group with ng-repeat", difference is in line UPD 1:我尝试调试angular.js,并且getControllers函数为“空手风琴组”和“具有ng-repeat的手风琴组”返回不同的值,但差异在一行
value = value || $element[retrievalMethod]('$' + require + 'Controller');
value is undefined for "ng-repeat acordion-group" and not null for "empty accordion group" “ ng-repeat acordion-group”的值是未定义的,“空手风琴组”的值不是null
UPD COMPLETE I'm update my VS2013 to RC2 and problems solved. UPD COMPLETE我将VS2013更新为RC2,问题已解决。
Thank you for having the time to provide a plunkr. 感谢您抽出宝贵的时间为您提供插件。 I modified it a bit by excluding the non-needed libs and also using
data-ng-xx
notation. 我通过排除不需要的库以及使用
data-ng-xx
表示法对它进行了一些修改。 I also used the appropriate way of injecting scope: 我还使用了适当的注入范围的方法:
['$scope', function($scope){
....
}]
I also put ng-app
on body and after head cause of a possible script loading order issue. 我还将
ng-app
放在正文上,然后放在可能导致脚本加载顺序问题的头后面。 Here is the Plunkr: 这是Plunkr:
http://plnkr.co/edit/Rftdxz4erSeHT14cp2ID?p=preview http://plnkr.co/edit/Rftdxz4erSeHT14cp2ID?p=preview
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.