我有一个表可排序列(根据排序存及其方向的头图标确定):更好的方式来使用纳克级
<table border="1">
<thead>
<tr>
<th>#</th>
<th ng-click="sort(studies, 'PatientName')" class="sortable"
ng-class="{'ascending': sortingField == 'PatientName' && sortingDirection == 'asc' ,
'decending': sortingField == 'PatientName' && sortingDirection == 'desc' }">PatientName</th>
</tr>
我觉得我在纳克级使用的是不好的做法,我该如何改进它?
我该如何避免重复检查,并且不需要重复'PatientName'字段,因为我需要使用不同名称的其他列。
非常感谢。
谢谢,但我仍然需要保持变量为每个列,我能避免它的基础上实际上只有一个字段可以 –
@DorCohen您可以使用一个对象:'ng-class =“headerClass ['PatientName']”'。您的控制器将负责填充阵列。 – sp00m