Javascript 带AngularJS的引导旋转木马中的动态背景色
我在引导旋转木马中有一个奇怪的行为,我正在使用AngularJS。下面是HTML代码,我试图在其中动态地为每个缩略图添加背景色。我观察到的情况如下:Javascript 带AngularJS的引导旋转木马中的动态背景色,javascript,jquery,css,angularjs,twitter-bootstrap,Javascript,Jquery,Css,Angularjs,Twitter Bootstrap,我在引导旋转木马中有一个奇怪的行为,我正在使用AngularJS。下面是HTML代码,我试图在其中动态地为每个缩略图添加背景色。我观察到的情况如下: 最初,carousel的“活动”部分会按预期为每个缩略图动态添加背景色 但是,一旦我开始旋转旋转转盘,所有缩略图都会失去其背景色 现在,当我重新加载页面时,所有缩略图都会重新获得背景色 所以我无法理解是什么导致了旋转过程中背景颜色的丢失?谢谢 <div class="well"> <div id="myCa
<div class="well">
<div id="myCarousel" class="carousel slide">
<!-- Carousel items -->
<div class="carousel-inner">
<div ng-repeat="imgSet in imgSets" ng-class="{item: true, active : $first}">
<div ng-class="row">
<div ng-repeat="img in imgSet track by img.id" class="col-sm-3">
<a href="/appDetail/{{img.id}}" class="thumbnail" style="background-color: {{img.tile_color}};">
<img ng-src="{{uri}}/{{img.image}}" alt="Image" class="img-responsive" height="{{img.tile_height}}" width="{{img.tile_width}}">
</a>
</div>
</div>
<!--/row-->
</div>
<!--/item-->
</div>
<!--/carousel-inner-->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">‹</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">›</a>
</div>
<!--/myCarousel-->
</div>
<!--/well-->
我发现了如何修复它,但我仍然不明白为什么原始版本不起作用(以及为什么修复程序起作用):
我的{img.tile_color}}是一个形式为“#1956B7”(或任何其他#)的字符串。我想号码前面一定有“#”的标志。当我移除“#”时,它开始工作 我发现了如何修复它,但我仍然不明白为什么原始版本不起作用(以及修复为什么起作用):
我的{img.tile_color}}是一个形式为“#1956B7”(或任何其他#)的字符串。我想号码前面一定有“#”的标志。当我移除“#”时,它开始工作 在这里,我试图用一个更简单的例子来重现这个问题。看起来我们需要用单引号来说明这一点,我试图用一个更简单的例子来重现这个问题。看来我们需要用单引号来说明这一点