2

The following code doesn't seem to work correctly:

<div ng-switch on="current">
    <div ng-repeat="solution in solutions" ng-switch-when="{{solution.title}}">
        {{solution.content}}
    </div>
</div>

The output of {{solution.title}} is literally {{solution.title}}. It doesn't get processed by angular.

Constantino Tsarouhas
  • 6,846
  • 6
  • 43
  • 54
Martin Christov
  • 155
  • 2
  • 9

1 Answers1

6

The ng-switch-when tag requires a constant, you can't put a variable in it. You can rework your code as follows:

<div ng-repeat="solution in solutions">
    <div ng-show="current == solution">
        {{solution.content}}
    </div>
</div>
remigio
  • 4,101
  • 1
  • 26
  • 28