我还是AngularJS的新手。我试图改变表格元素的颜色,使其黄色,如果用户投票选择。有条件地改变angularjs元素的颜色?
<div ng-show="poll.userVoted">
<table class="result-table">
<tr ng-repeat="choice in poll.choices">
<td>{{choice.text}}</td>
<td>
<table ng-if="choice.text == poll.userChoice.text" style="background-color: yellow; width: {{choice.votes.length/poll.totalVotes*100}}%; text-align: right">
<tr>
<td>{{choice.votes.length}}</td>
</tr>
</table>
<table ng-if="choice.text != poll.userChoice.text" style="background-color: lightblue; width: {{choice.votes.length/poll.totalVotes*100}}%; text-align: right">
<tr>
<td>{{choice.votes.length}}</td>
</tr>
</table>
</td>
</tr>
</table>
什么错误? – hfarazm 2014-09-29 05:39:52
你可以尝试这样的事情,如果我正确理解你的问题标题 - http://plnkr.co/edit/jeszGorMQmLiqhtWDt94?p=preview – swapnesh 2014-09-29 05:44:57
谢谢我将prob做这样的事情。我只是觉得我可以在某种程度上做到这一点,而不用为它制作功能。 – jsky 2014-09-29 06:11:22