我有以下HTML / AngularJS代码:
<span ng-show="true" ng-repeat="timeRangeObject in timeRangeObjects" ng-if="ifExpression">
<span class="progress-bar progress-bar-{{timeRangeObject.type}}" style="width: {{timeRangeObject.percentage}}%" />
</span>
此代码的结果是:
<span>
<span class="progress-bar ...
</span>
<span>
<span class="progress-bar ...
</span>
<span>
<span class="progress-bar ...
</span>
<span>
<span class="progress-bar ...
</span>
但我绝对需要这个:
<span>
<span class="progr ...
<span class="progr ...
<span class="progr ...
<span class="progr ...
</span>
有可能这样做吗?
非常感谢!
答案 0 :(得分:4)
将ng-repeat
放到内跨区域。我删除了ng-show=true
部分,这是不必要的。
<span ng-if="ifExpression">
<span ng-repeat="timeRangeObject in timeRangeObjects" class="progress-bar progress-bar-{{timeRangeObject.type}}" style="width: {{timeRangeObject.percentage}}%" />
</span>