我目前正在构建标题图像的幻灯片,然后单击选择并设置该标题图像以替换旧图像。到目前为止,这是我的代码:
var app = angular.module('plunker', []);
app.controller('BannerCtrl', function($scope) {
var imageCounter = 0;
$scope.nextButton = function () {
imageCounter = imageCounter + 1;
if (imageCounter === 1) {
$scope.carouselState = 'second-slide';
}
if (imageCounter === 2) {
$scope.carouselState = 'third-slide';
}
if (imageCounter > 2) {
imageCounter = 0;
$scope.carouselState = 'reset-slide';
}
};
$scope.previousButton = function () {
imageCounter = imageCounter - 1;
if (imageCounter < 0) {
imageCounter = 2;
$scope.carouselState = 'third-slide';
}
if (imageCounter === 1) {
$scope.carouselState = 'second-slide';
}
if (imageCounter === 0) {
$scope.carouselState = 'reset-slide';
}
};
$scope.setHeader = function () {
if (imageCounter === 0) {
$scope.currentbannerImage = '/styles/img/banner-default1.jpg';
$scope.bannerState = '';
}
};
$scope.currentbannerImage = [
{
src: "1.jpg"
}
];
$scope.bannerImages = [
{
src: "2.jpg"
},
{
src: "3.jpg"
},
{
src: "4.jpg"
}
];
});
我还设置了一个 Plunker,以展示我的目标!
http://plnkr.co/edit/vRexvso9RvLwyKK1vcKZ
请有人可以帮我用其他“bannerImages”之一替换“currentBannerImage”吗?
谢谢,
J.P