采用NG-重复和纳克级上表内的行
我使用AngularJS,我想会是类似于这会产生什么效果,假设它会工作(它没有)。
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).
查看
<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>
控制器
$scope.rowClass = function(person){
...return some value based upon some property of person...
}
我知道这code不会起作用,因为人
不可用纳克级
作为它只会提供给每一行中的对象。在code是得到我想要传达给做的想法:即。我希望能有正在使用创建的 NG-重复
的类也是基于这取决于获得行本身如的范围功能的情况表行。 人
。我知道我的会只需添加上的列纳克级但那是无聊。任何人有任何更好的想法?
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?
这实际上应该很好地工作。人应该可以在其子tr元素上以及因为它们共享相同的范围。
This should actually work fine. Person should be available on the tr element as well as on its children since they share the same scope.
这似乎很好地工作对我来说:
This seems to work fine for me:
<table>
<tr ng-repeat="person in people" ng-class="rowClass(person)">
<td>{{ person.name }}</td>
</tr>
</table>