0

I have the following HTML/AngularJS code:

<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>

The result of this code is:

<span>
    <span class="progress-bar ...
</span>
<span>
    <span class="progress-bar ...
</span>
<span>
    <span class="progress-bar ...
</span>
<span>
    <span class="progress-bar ...
</span>

but I would absolutely need this one:

<span>
    <span class="progr ...
    <span class="progr ...
    <span class="progr ...
    <span class="progr ...
</span>

Is there any possibility to do it like this?

Thanks a lot!

2 Answers 2

4

Just put ng-repeat onto inner span. I removed the ng-show=true part, it is unnecessary.

<span ng-if="ifExpression">
    <span ng-repeat="timeRangeObject in timeRangeObjects" class="progress-bar progress-bar-{{timeRangeObject.type}}" style="width: {{timeRangeObject.percentage}}%" />
</span>
Sign up to request clarification or add additional context in comments.

Comments

0

The following should work for you:

<span 
    ng-repeat="timeRangeObject in timeRangeObjects" class="progress-bar progress-bar-{{timeRangeObject.type}}" style="width: {{timeRangeObject.percentage}}%" >
</span>

You can wrap your ng-if expression around the repeated span if you need it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.