gpt4 book ai didi

AngularJS 错误 - [$compile :multidir] Multiple directives error

转载 作者:行者123 更新时间:2023-12-02 22:06:42 25 4
gpt4 key购买 nike

我使用这些软件包:来自 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 ...

模板文件是这样的:

<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>

和 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 ...) });
}]);

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');
};
};

我该如何修复它?告诉我是否需要更多信息。谢谢。

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

最佳答案

名为 slide 的指令看起来同时存在于 angular-flexsliderui.bootstrap.carousel 中。如果您不需要轮播,请尝试构建不支持轮播的 AngularUI Bootstrap。

看起来 Angular 使用的是 boostrap slide 而不是 flexslider slide 并且 bootstrap 需要嵌入,而 flex-slider 也需要嵌入 code>,因此存在关于哪一个优先的冲突。

您也可以通过调整加载顺序来解决此问题,但我不确定。

关于AngularJS 错误 - [$compile :multidir] Multiple directives error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19131617/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com