如何更改“材料设计"按钮行中所选按钮的外观? [英] How do I change the appearance of the selected button in a row of Material Design buttons?
本文介绍了如何更改“材料设计"按钮行中所选按钮的外观?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个HTML表,在几行中,每个单元格中都有一个Material Design按钮,该按钮是使用AngularJS动态生成的.
I have a HTML table and in several rows I have a Material Design button in each cell, dynamically generated using AngularJS.
<table class="plans">
<tbody>
<tr>
<td>Work Plans</td>
<td ng-click="pbmainController.selectPlan(plan.planName)"
ng-repeat="plan in pbmainController.planList">
<md-button class="md-raised">{{plan.planName}}</md-button>
</td>
</tr>
</tbody>
</table>
一次只能选择一个按钮(即单选按钮).
Only one of button can be selected at a time (i.e. like a radio button).
如何更改所选按钮的颜色?
How do I change the color of the selected button?
推荐答案
我通过使用三元运算符将ng-class
放在按钮上来使其工作
I got it to work by putting the ng-class
on the button, using the ternary operator
<table class="plans">
<tbody>
<tr>
<td>Work Plans</td>
<td ng-click="pbmainController.selectPlan(plan.planName)"
ng-repeat="plan in pbmainController.planList">
<md-button ng-class="plan.planName == selectedPlanName ? 'md-raised md-primary' : 'md-raised'">{{plan.planName}}</md-button>
</td>
</tr>
</tbody>
</table>
这篇关于如何更改“材料设计"按钮行中所选按钮的外观?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文