我有一个基于 switch 的 div,但 switch 有一个 bool 变量,但该值将根据 row.id 进行评估。有人可以告诉我我在这里做错了什么吗?
<div ng-switch="hasUrl">
<a ng-switch-when="row.id.indexOf(':') < 0 === true" href="{{url + row.id}}"> <!-- hasUrl = true -->
{{getName(row)}}
</a>
<a ng-switch-default href=".......">
{{getName(row)}}
</a>
</div>
最佳答案
您不需要 ===
,请将其删除。
<div ng-switch="hasUrl">
<a ng-switch-when="row.id.indexOf(':') < 0" href="{{url + row.id}}"> <!-- hasUrl = true -->
{{getName(row)}}
</a>
<a ng-switch-default href=".......">
{{getName(row)}}
</a>
关于javascript - Angular js : Dynamic expression not working for ng-switch-when,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41495022/