I have created a slideshow app using AngularJS that uses Instagram photos filtered by a specific tag. Here is the demo and the GitHub repo.
What is the most efficient way of looping through those images according to the principles of AngularJS?
Currently I use a $timeout which moves the first element to the bottom of the images array in combination with CSS which hides every other image except the first one:
$scope.images = [
'image-001.jpg',
'image-002.jpg',
'image-003.jpg'
];
$timeout( function advanceSlide() {
$scope.images.push( $scope.images.shift() );
$timeout( advanceSlide, 6000 );
);
Demo: http://jsfiddle.net/YruT6/1/
The other option would be to walk the photos object and apply an active class, like illustrated here. Would that be less resource intensive?