gpt4 book ai didi

angularjs - 使用 ui.bootstrap 导致轮播出现问题

转载 作者:行者123 更新时间:2023-12-02 01:48:21 24 4
gpt4 key购买 nike

我在使轮播正常工作时遇到问题。我使用 yeomen 来搭建 Angular 应用程序。我收到此错误

Error: [$compile:ctreq] Controller 'carousel', required by directive 'slide', can't be found!
http://errors.angularjs.org/1.2.26/$compile/ctreq?p0=carousel&p1=slide
at http://localhost:9000/bower_components/angular/angular.js:78:12
at getControllers (http://localhost:9000/bower_components/angular/angular.js:6543:19)
at nodeLinkFn (http://localhost:9000/bower_components/angular/angular.js:6712:35)
at http://localhost:9000/bower_components/angular/angular.js:6913:13
at http://localhost:9000/bower_components/angular/angular.js:8113:11
at wrappedCallback (http://localhost:9000/bower_components/angular/angular.js:11573:81)
at wrappedCallback (http://localhost:9000/bower_components/angular/angular.js:11573:81)
at http://localhost:9000/bower_components/angular/angular.js:11659:26
at Scope.$eval (http://localhost:9000/bower_components/angular/angular.js:12702:28)
at Scope.$digest (http://localhost:9000/bower_components/angular/angular.js:12514:31) <div ng-class="{
'active': leaving || (active &amp;&amp; !entering),
'prev': (next || active) &amp;&amp; direction=='prev',
'next': (next || active) &amp;&amp; direction=='next',
'right': direction=='prev',
'left': direction=='next'
}" class="left carousel-control item text-center ng-isolate-scope" ng-transclude="" href="#Carousel" data-slide="prev"> angular.js:10072
Error: [$compile:ctreq] Controller 'carousel', required by directive 'slide', can't be found!
http://errors.angularjs.org/1.2.26/$compile/ctreq?p0=carousel&p1=slide
at http://localhost:9000/bower_components/angular/angular.js:78:12
at getControllers (http://localhost:9000/bower_components/angular/angular.js:6543:19)
at nodeLinkFn (http://localhost:9000/bower_components/angular/angular.js:6712:35)
at http://localhost:9000/bower_components/angular/angular.js:6913:13
at http://localhost:9000/bower_components/angular/angular.js:8113:11
at wrappedCallback (http://localhost:9000/bower_components/angular/angular.js:11573:81)
at wrappedCallback (http://localhost:9000/bower_components/angular/angular.js:11573:81)
at http://localhost:9000/bower_components/angular/angular.js:11659:26
at Scope.$eval (http://localhost:9000/bower_components/angular/angular.js:12702:28)
at Scope.$digest (http://localhost:9000/bower_components/angular/angular.js:12514:31) <div ng-class="{
'active': leaving || (active &amp;&amp; !entering),
'prev': (next || active) &amp;&amp; direction=='prev',
'next': (next || active) &amp;&amp; direction=='next',
'right': direction=='prev',
'left': direction=='next'
}" class="right carousel-control item text-center ng-isolate-scope" ng-transclude="" href="#Carousel" data-slide="next"> angular.js:10072

这是我的 html 文件

 <style>
#slides_control > div{
height: 200px;
}
img{
margin:auto;
width: 400px;
}
#slides_control {
position:absolute;
width: 400px;
left:50%;
top:20px;
margin-left:-200px;
}
.carousel-control.right {
background-image: linear-gradient(to right, rgba(0, 0, 0, .0001) 0%, rgba(237, 232, 232, 0.5) 100%) !important;
}
.carousel-control.left {
background-image: linear-gradient(to right, rgba(249, 248, 248, 0.5) 0%, rgba(0, 0, 0, .0001) 100%) !important;
}
</style>
<div id="Carousel" class="carousel slide">
<ol class="carousel-indicators">
<li data-target="Carousel" data-slide-to="0" class="active"></li>
<li data-target="Carousel" data-slide-to="1"></li>
<li data-target="Carousel" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="item active">
<img src="images/sliders/main_page_slider/PhoneApp_Website_Home_41.png" class="img-responsive">
</div>
<div class="item">
<img src="images/sliders/main_page_slider/PhoneApp_Website_Home_45.png" class="img-responsive">
</div>
<div class="item">
<img src="images/sliders/main_page_slider/PhoneApp_Website_Home_49.png" class="img-responsive">
</div>
</div>
<a class="left carousel-control" href="#Carousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="right carousel-control" href="#Carousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>

我的 Controller 是

'使用严格';

angular.module('myhApp') .controller('MainCtrl', 函数 ($scope) { });

这是我的 app.js

angular
.module('myhApp', [
'ngAnimate',
'ngCookies',
'ngResource',
'ngRoute',
'ngSanitize',
'ngTouch',
'ui.bootstrap'
])
.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/main.html',
controller: 'MainCtrl'
})
.when('/about', {
templateUrl: 'views/about.html',
controller: 'AboutCtrl'
})
.otherwise({
redirectTo: '/'
});
});

我不确定是什么原因造成的。任何帮助将不胜感激。

** 最近的一些发现 **

好吧,我做了一些挖掘,发现我必须在 dom 中为指令设置轮播(如错误所示)。当我添加轮播时,错误消失了,但我的轮播不再工作,而且看起来也很奇怪。

这是我对 html 所做的更改

<div id="Carousel" class="carousel slide" carousel>

这是它的外观,您可以看到猫脸上有一个额外的箭头。我不知道发生了什么......任何帮助将不胜感激

enter image description here

enter image description here

最佳答案

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

  <a data-slide="prev" href="#clients-slider" ng-non-bindable class="left carousel-control">‹</a>

关于angularjs - 使用 ui.bootstrap 导致轮播出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26332202/

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