Domanda

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.

È stato utile?

Soluzione

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>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top