Question

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.

Était-ce utile?

La solution

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>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top