Ternary operator in AngularJS templates
How do you do a ternary with AngularJS (in the templates)? It would be nice to use some in html attributes (classes and style) instead of creating and calling a function of the controller. Mark Rajcok Update : Angular 1.1.5 added a ternary operator , so now we can simply write <li ng-class="$first ? 'firstRow' : 'nonFirstRow'"> If you are using an earlier version of Angular, your two choices are: (condition && result_if_true || !condition && result_if_false) {true: 'result_if_true', false: 'result_if_false'}[condition] item 2. above creates an object with two properties. The array syntax is