94
rated 0 times
[
99]
[
5]
/ answers: 1 / hits: 32404
/ 11 Years ago, thu, april 25, 2013, 12:00:00
I am currently building a slideshow of header images, then on click select and set that header image to replace the old one. This is my code so far:
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
}
];
});
I have also set up a Plunker, to demonstrate what I am on about!
http://plnkr.co/edit/vRexvso9RvLwyKK1vcKZ
Please can someone help me to replace the 'currentBannerImage' with one of the other 'bannerImages'?
Thanks,
JP
More From » angularjs