After using angularJS, I found myself wondering how to effectively implement its if statement in a particular way. I hope that my example will help clarify my question.
Here is the if statement I am working with:
<div data-ng-if="book.Availability>0">
<div class="col-xs-12 col-md-12 nopadding" style="border-right:solid 6px blue">
//some html div's here with angularJS
</div>
</div>
<div data-ng-if="book.Availability==0">
<div class="col-xs-12 col-md-12 nopadding" style="border-right:solid 6px red">
//some html div's here with angularJS
</div>
</div>
In this code, the content within
//some html div's here with angularJS
is the same for both if statements, with the only difference being the color of the container (red
and blue
).
I believe this code is redundant. Is there a way to use the same content for both if statements?
I attempted the following approach:
<div data-ng-if="book.Availability>0">
<div class="col-xs-12 col-md-12 nopadding" style="border-right:solid 6px blue">
</div>
<div data-ng-if="book.Availability==0">
<div class="col-xs-12 col-md-12 nopadding" style="border-right:solid 6px red">
</div>
`//some html div's here with angularJS`
However, this did not produce the desired output.
Thank you for any assistance with this issue.
I realize that my question may not fully capture what I am trying to achieve, but I am struggling to articulate it clearly.