无法找到指令所需的AngularJS控制器

时间:2014-04-09 14:24:22

标签: angularjs angularjs-directive angularjs-ng-repeat angular-ui angular-ui-bootstrap

我对每条“消息”都有错误

Error: [$compile:ctreq] Controller 'accordion', required by directive 'accordionGroup', can't be found!

我的代码在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>

但是消息是没有问题的视图

UPD 1: 我试图调试angular.js和函数getControllers为“空手风琴组”和“手风琴组与ng-repeat”返回不同的值,差异在行

value = value || $element[retrievalMethod]('$' + require + 'Controller');
对于“ng-repeat acordion-group”,

值未定义,而对于“空手风琴组”,

值不为空

UPD COMPLETE 我将我的VS2013更新为RC2并解决了问题。

1 个答案:

答案 0 :(得分:1)

感谢您抽出时间提供一名助手。我通过排除不需要的库并使用data-ng-xx表示法对其进行了一些修改。我还使用了适当的注入范围方式:

['$scope', function($scope){
....
}]

我还将ng-app置于正文和可能的脚本加载订单问题之后。这是Plunkr:

http://plnkr.co/edit/Rftdxz4erSeHT14cp2ID?p=preview

相关问题