I'm working on setting up a simple image gallery where I can dynamically change the displayed image by setting a specific number for currentImage.
Check out my HTML code:
<div class="main_image" ng-switch on="current_image">
<img ng-repeat="image in sorted_images" ng-src="{{ image.large }}" class="image {{ $index }}" ng-switch-when="{{ $index }}">
<img ng-src="{{ sorted_images[0].medium }}" class="image 0" ng-switch-default >
</div>
Snippet from the controller (written in CoffeeScript):
main_image = el.find('.main_image');
main_image.on('click', ->
scope.current_image = 1
It seems like even though my controller is updating the current_image variable, the switch doesn't happen. Could it be because of $index? I'm not sure. Can ng-switch be used within ng-repeat as shown in my example above?
Appreciate any help!