使用ui.bootstrap旋转木马导致问题 [英] using ui.bootstrap causing issues with carousel
问题描述
我有越来越传送带正常工作的问题。我用自耕农脚手架角应用。
我收到此错误
I am having issues with getting the carousel working properly. I used yeomen to scaffold the angular app. I am getting this error
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 && !entering),
'prev': (next || active) && direction=='prev',
'next': (next || active) && 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 && !entering),
'prev': (next || active) && direction=='prev',
'next': (next || active) && 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文件
here is my html file
<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>
我的控制器是
使用严格;
angular.module('myhApp')
.controller('MainCtrl',函数($范围){
});
angular.module('myhApp') .controller('MainCtrl', function ($scope) { });
这是我的app.js
here is my 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: '/'
});
});
我不知道什么导致它。任何帮助将AP preciated。
I am not sure whats causing it. Any help will be appreciated.
**一些最近的研究结果**
** Some findings recently **
好,我做了一些挖四周,发现我必须有在DOM的指令旋转木马(如错误指示)。当我添加旋转木马,该错误消失,但我的旋转木马犯规工作了,看起来靠不住的为好。
ok I did some digging around and found out that I have to have carousel in the dom for directive (as the error indicates). When I add carousel, the error goes away but my carousel doesnt work anymore and looks wonky as well.
下面是我为HTML
<div id="Carousel" class="carousel slide" carousel>
下面是它的外观,你可以看到有一个额外的箭头,猫脸。我不知道什么going..any帮助将AP precitaed
here is how it looks and you can see there is an extra arrow in the cats face. I am not sure whats going..any help will be apprecitaed
推荐答案
我能够加入到解决冲突的NG-非绑定到具有数据滑动指令的元素。见下图:
I was able to solve the conflict by adding the ng-non-bindable to the elements that have the data-slide directive. see below:
<a data-slide="prev" href="#clients-slider" ng-non-bindable class="left carousel-control">‹</a>
这篇关于使用ui.bootstrap旋转木马导致问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!