Reputation: 4217
I'm new to AngularJS
, I'm using
<div class="imageslide" ng-switch='slideshow' ng-animate="'animate'">
<div ng-repeat="img in images">
<div class="slider-content" ng-switch-when='$index'>
<!-- <p>Slider's are amazing1!</p> -->
<img ng-src="{{img.image_thumb}}">
</div>
</div>
</div>
When I'm using ng-switch-when='1'
it is working but, I'm trying to ng-switch-when
works dynamic with the index if current loop element.
Please help!
Upvotes: 0
Views: 509
Reputation: 1652
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.records = [
"Alfreds Futterkiste",
"Berglunds snabbköp",
"Centro comercial Moctezuma",
"Ernst Handel",
]
});
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body ng-app="myApp" ng-controller="myCtrl">
<h1 ng-repeat="x in records">
<div ng-switch="$index">
<span style="color: red" ng-switch-when="1">{{x}}</span>
<span style="color: blue" ng-switch-when="2">{{x}}</span>
<span style="color: green" ng-switch-when="2">{{x}}</span>
</div>
</h1>
</body>
</html>
Upvotes: 1