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



以下代码似乎无法正常工作:

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

{{solution.title}}的输出实际上是{{solution.title}}。它不会被角度处理。

当标记需要常量时,ng开关不能在其中放入变量。您可以按如下方式重新编写代码:

<div ng-repeat="solution in solutions">
    <div ng-show="current == solution">
        {{solution.content}}
    </div>
</div>

最新更新