0

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!

4

1 Answer 1

1

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>

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.