I am currently developing an application using AngularJs and Bootstrap. My goal is to display the title of a 'scenario' with different styling based on its status, along with a specific icon.
Initially, I attempted the following approach:
<span class="text-success" data-ng-if="scenario.status=='success'"><i class="fa fa-check-circle"></i>Scenario {{scenario.title}}</span>
<span class="text-danger" data-ng-if="scenario.status=='fail'"><i class="fa fa-exclamation-circle"></i>Scenario {{scenario.title}}</span>
<span data-ng-if="scenario.status=='none'">Scenario {{scenario.title}}</span>
This method has been effective so far. However, I would like to enhance it by utilizing ng-class to avoid code duplication. I have made the following modifications:
<span ng-class="{text-success:scenario.status=='success' || text-danger:scenario.status=='fail'}">Scenario {{scenario.title}}
<i ng-class="{fa fa-check-circle:scenario.status=='success' || fa fa-exclamation-circle:scenario.status=='fail'}"></i>
</span>
Unfortunately, this new approach does not seem to work as expected, and I am having trouble identifying the issue. Any assistance would be greatly appreciated.
Thank you!