2014-02-18 63 views
0

民间我使用简单的ng-repeat指令来显示表格中的数据。 但是,当指令呈现时,第一列将占用所有空间并对表格进行分解。ng-repeat表格显示不正确

看看这里的plnkr: http://plnkr.co/edit/Hahh4uyQ130zOS8noC3D

请关注上档的layout.html

<table> 
    <thead> 
    <tr ng-repeat="element in header" class="header-cells" style="width:{{element.width}}px"> 
     <th drop-down-sort-menu>{{element.column}}</th> 
    </tr> 
    </thead> 

    <tbody> 
    <tr ng-repeat="element in body"> 
     <td ng-repeat="h in header" row="{{$parent.$index}}" col="{{$index}}" style="width:{{element.width}}px">{{element[h.column]}} 
     </td> 
    </tr> 
    </tbody> 
</table> 

我相信它的一些次要的。任何线索

+1

你有几个问题。 http://plnkr.co/edit/coVXMyzSGKF0EdrkObsL?p=preview我无法发布答案,因为有人标记了你的帖子。 –

+0

@詹姆斯,最好让你的问题更清楚些,以避免被标记出来。 –

+0

克雷格..你的解决方案工作..感谢很多..我不能标记你的答案是正确的,不幸的是, – runtimeZero

回答

0

我相信你的问题是,对于标题,你有4个TR只有一个TH,而不是一个TR有4个TH。出于这个原因,标题上的单元格与您身体上的单元格不匹配。

在TH级别执行第一个ng-repeat。

试一试,让我知道。