I am using AngularJS and the effect I want to get would be something similar to what this would produce, assuming it would work (which it doesn't).
View
<tr ng-repeat='person in people' ng-class='rowClass(person)'>
<td>.....info about person...</td>
<td>.....info about person...</td>
<td>.....info about person...</td>
</tr>
Controller
$scope.rowClass = function(person){
...return some value based upon some property of person...
}
I realise that this code won't work because person
is unavailable to ng-class
as it will only be available to objects inside each row. The code is to get the idea of what I'm trying to do across: ie. I want to be able to have table rows that are created using ng-repeat
whose class is also based on a condition which depends on access to the scoped feature of row itself eg. person
. I realise I could just add ng-class on the columns but that is boring. Anyone have any better ideas?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…