javascript - AngularJS if statement condition in an ng-repeat -
i'm using ng-repeat
in angularjs
<ul> <li ng-repeat="question in questions" class="question list-group-item media"> <span class="question__type">{{ question.question }}</span> <br> <div class="btn-group question__answer justified nav-tabs"> <a class="btn {{question.type}}" ng-repeat="answer in question.answers">{{ answer }}</a> </div> </li> </ul>
i want able make section below if statement if {{question.type}} == 'radio' justified
on btn-group
div.
<div class="btn-group question__answer justified nav-tabs"> <a class="btn {{question.type}}" ng-repeat="answer in question.answers">{{ answer }}</a> </div>
you can use ng-class
. here jsbin demonstrating works. i've made justified
class change text color red.
<div class="btn-group question__answer nav-tabs" ng-class="{justified: question.type == 'radio'}"> <a class="btn {{question.type}}" ng-repeat="answer in question.answers">{{ answer }}</a> </div>
Comments
Post a Comment