代码转自http://angular-ui.github.io/bootstrap/,有修改,加注释:
html
<div class="row rollpic-div" style="height: 540px">
<div class="inner">
<div style="height: 540px">
<div>
<uib-carousel interval="myInterval" no-wrap="false">
<uib-slide ng-repeat="slide in slides" active="slide.active">
<img ng-src="{{slide.image}}" style="margin:auto;">
<div class="carousel-caption button-caption">
<a href="/dhc/submit" class="roll_button">立即体验</a>
</div>
</uib-slide>
</uib-carousel>
</div>
</div>
</div>
</div>
css
.carousel-control {
display: none;
}
.carousel-caption {
text-shadow: none;
}
var app = angular.module('dhc');
app.registerController('indexController', function ($scope)//indexController见router.js
{
$scope.myInterval = 3000;//循环间隔 3s
//$scope.noWrapSlides = false;//是否循环
var slides = $scope.slides = [];//初始化
$scope.totop = function()
{
//javascript:
window.scrollTo(0,0);
}
/* var newWidth = 600 + slides.length + 1;
slides.push
({
image: '//placekitten.com/' + newWidth + '/300',
text: ['More','Extra','Lots of','Surplus'][slides.length % 4] + ' ' + ['Cats', 'Kittys', 'Felines', 'Cutes'][slides.length % 4]
});
};
for (var i=0; i<4; i++)
{
$scope.totop();
}*/
slides.push({image: __uri('./images/index_3.png')});//js里要用__uri,最终线上fis才能将其转化成绝对路径/statics/的形式
slides.push({image: __uri('./images/index_12.png')});
});