AngularJS错误 - [$ compile:multidir]多指令错误

Mor*_*yae 12 angularjs angular-ui

我使用这些包:angular-ui包中的angularjs模式:http: //angular-ui.github.io/bootstrap/#/modal和Angular-flexslider来自:https://github.com/EnthusiasticCode/angular- flexslider

每个插件在单独的页面中都能很好地工作.但是当我在一个页面中使用它们时,angular-flexslider会导致错误:

Error: [$compile:multidir] Multiple directives [flexSlider, slide] asking for transclusion on: <div class="flexslider-container ng-isolate-scope ng-scope" slide="s in slides" animation="slide">
http://errors.angularjs.org/1.2.0-rc.2/$compile/multidir?p0=flexSlider&p1=s…20ng-scope%22%20slide%3D%22s%20in%20slides%22%20animation%3D%22slide%22%3E
    at ...
Run Code Online (Sandbox Code Playgroud)

模板文件是这样的:

<flex-slider slide="s in slides" animation="slide">
    <li>
        <img ng-src="{{s}}">
    </li>
</flex-slider>

<div ng-controller="ModalDemoCtrl">
    <script type="text/ng-template" id="myModalContent.html">
        <h3>I'm a modal!</h3>
    </script>

    <button class="btn" ng-click="open()">Open me!</button>
</div>
Run Code Online (Sandbox Code Playgroud)

和app.js文件:

angular.module('theApp', ['theApp.filters', 'theApp.services', 'theApp.directives', 'theApp.controllers', 'ngRoute', 'ngSanitize', 'angular-flexslider', 'ui.bootstrap']).
  config(['$routeProvider', function($routeProvider) {
    $routeProvider.
        when('/home', {templateUrl: (someurl...) , controller: (a name ...) });
  }]);
Run Code Online (Sandbox Code Playgroud)

controller.js文件是:

angular.module('theApp.controllers', [])
 .controller('SliderMedium', [ '$scope', function($scope) {
   $scope.slides = [
     'images/slider/01.png',
     'images/slider/02.png',
   ];
 }]);

// ========= THIS IS controllers from angular-ui with no modification =======:
// ==========================================================================
var ModalDemoCtrl = function ($scope, $modal) {

  $scope.items = ['item1', 'item2', 'item3'];

  $scope.open = function () {

    var modalInstance = $modal.open({
      templateUrl: 'myModalContent.html',
      controller: ModalInstanceCtrl,
      resolve: {
        items: function () {
          return $scope.items;
        }
      }
    });
  };
};

var ModalInstanceCtrl = function ($scope, $modalInstance, items) {

  $scope.items = items;
  $scope.selected = {
    item: $scope.items[0]
  };

  $scope.ok = function () {
    $modalInstance.close($scope.selected.item);
  };

  $scope.cancel = function () {
    $modalInstance.dismiss('cancel');
  };
};
Run Code Online (Sandbox Code Playgroud)

我该如何解决?告诉我是否需要进一步的信息.谢谢.

更新:删除了不必要的html标记,添加了controller.js和app.js内容.

Jus*_*nen 10

命名的指令slide看起来都在angular-flexsliderui.bootstrap.carousel.如果您不需要轮播,请尝试在没有轮播支持的情况下构建AngularUI Bootstrap.

看起来angular似乎是使用了boostrap slide而不是flexslider slide,而bootstrap需要进行翻译,这也是flex-slider一个冲突,因为哪个优先.

您也可以通过摆弄加载顺序来解决这个问题,但我不确定.


LX7*_*LX7 5

为了避免与引导传送带thenikso /角flexslider冲突增添了新的指令flex-slide沿slide.

Bootstrap用户可以使用flex-slide而不是slide指令.

<flex-slider flex-slide="s in slides" animation="slide">
    <li>
        <img ng-src="{{s}}">
    </li>
</flex-slider>
Run Code Online (Sandbox Code Playgroud)