1

概括 :

每当我尝试使用data-slidein 时HTML DOM,我的 js 控制台中都会出现此错误:

错误:[$compile:ctreq] 控制器 'carousel',指令 'slide' 需要,找不到!

我用 bootstrap 和 angularjs 创建了一个应用程序。我已经添加了这个库<script type="text/javascript" src="/bower_components/bootstrap/dist/js/bootstrap.js"></script>

ui.bootstrap创建我的应用程序时,我已将其作为依赖项包含在内。

整个错误:

Error: [$compile:ctreq] Controller 'carousel', required by directive 'slide', can't be found!
http://errors.angularjs.org/1.4.10/$compile/ctreq?p0=carousel&p1=slide
    at angular.js:68
    at getControllers (angular.js:8432)
    at nodeLinkFn (angular.js:8570)
    at angular.js:8810
    at processQueue (angular.js:15097)
    at angular.js:15113
    at Scope.$eval (angular.js:16359)
    at Scope.$digest (angular.js:16175)
    at Scope.$apply (angular.js:16467)
    at done (angular.js:10852)

模板的相关部分:

<div id="carousel-example-generic" class="carousel" data-ride="carousel" data-interval="false">
                        <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
                            <span class="glyphicon glyphicon-triangle-left" aria-hidden="true"></span>
                            <span class="sr-only">Previous</span>
                        </a>
                        <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
                            <span class="glyphicon glyphicon-triangle-right" aria-hidden="true"></span>
                            <span class="sr-only">Next</span>
                        </a>
</div>

当我删除并且此错误不会出现时data-slide="prev"data-slide="next"

任何直接的帮助都将是非常可观的。谢谢。

4

1 回答 1

14

我能够通过添加到具有指令ng-non-bindable的元素来解决冲突:data-slide

  <a data-slide="prev" href="#clients-slider" ng-non-bindable class="left carousel-control">‹&lt;/a>
于 2016-05-15T08:06:12.067 回答