我正在努力使用ng-table以表格方式显示报告.但是,我遇到了使用data-title属性并动态分配标题的问题.
在以下示例中,我尝试按如下方式设置data-title属性.
<td ng-repeat="field in user" data-title="'{{ fields[$index] }}'">
{{ field }}
</td>
Run Code Online (Sandbox Code Playgroud)
$scope.fields = ["Names", "Ages"];在控制器中定义.检查元素时,data-title属性已正确设置,但标题未正确处理,导致标题为{{fields [$ index]}}.
这是一个实例:http://plnkr.co/edit/gBS6FGINayYufPGqCMxb?p = preview
1stofall,你有不必要''的{{fields[$index]}}。
第二 - 是的,它可以是动态的:字段数组项目桅杆具有标题属性。
<table ng-table-dynamic="tableParams with columns" show-filter="false" class="table table-bordered table-striped">
<tbody>
<tr ng-repeat="user in $data">
<td ng-repeat="col in $columns">{{user[col.field]}}</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
我已经为您编辑了 ngTable 旧网站上的旧示例。
您应该使用此示例 -更新示例 20:动态列