My website has a slideshow feature with left and right buttons, similar to this example: .
I am using Angular to change the image when the left or right button is clicked.
In the function, I am incrementing a value:
/*SlideShow Pictures*/
$scope.picture_1 = "./images/photos/watch.jpg";
$scope.picture_2 = "./images/photos/watch.jpg";
$scope.picture_3 = "./images/photos/watch.jpg";
$scope.picture_4 = "./images/photos/watch.jpg";
$scope.picture = $scope.picture_1;
$scope.picture_value = 1;
$scope.image_change_right = function () {
if ($scope.picture_value < 4)
{
$scope.picture_value = $scope.picture_value + 1;
$scope.picture = ('$scope.picture_' + $scope.picture_value);
console.log($scope.picture_value);
}
else{
$scope.picture_value = 1;
$scope.picture = ('$scope.picture_' + $scope.picture_value);
console.log($scope.picture_value);
}
}
This function is triggered when the right button is pressed.
The issue is that even though the value is correctly shown in the console log, it seems like it is being treated as a string rather than a variable. How can I ensure that the value is assigned to the scope.picture variable correctly?
Any help or advice would be greatly appreciated. Thank you!