Martin Christov
Martin Christov

Reputation: 155

Angularjs: ng-repeat + ng-switch-when != expected

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.

Upvotes: 2

Views: 3742

Answers (1)

remigio
remigio

Reputation: 4211

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>

Upvotes: 6

Related Questions