I want to present the model data as different images using Angular, but there are some problems finding the βrightβ way to do this. Angular APIs in expressions say conditional expressions are not allowed ...
Simplifying simplification, model data is retrieved via AJAX and shows the status of each interface on the router. Something like:
$scope.interfaces = ["UP", "DOWN", "UP", "UP", "UP", "UP", "DOWN"]
So, in Angular we can display the state of each interface with something like:
<ul> <li ng-repeat=interface in interfaces>{{interface}} </ul>
BUT. Instead of values ββfrom the model, I would like to show a suitable image. Something after this general idea.
<ul> <li ng-repeat=interface in interfaces> {{if interface=="UP"}} <img src='green-checkmark.png'> {{else}} <img src='big-black-X.png'> {{/if}} </ul>
(I think Ember supports this type of construct)
Of course, I could change the controller to return image urls based on the actual model data, but this seems to violate the separation of model and view, no?
This SO publication suggested using the directive to change the source of bg-img. But then we went back to placing the URLs in JS, not in the template ...
All suggestions are appreciated. Thank you
sorry for any typos
angularjs
Danny Dec 22 '12 at 2:50 2012-12-22 02:50
source share