例如,我有一个智能表,我使用smart table angularjs module创建并跟随SO answer:
<table st-table="positions" class="table">
<thead>
<tr>
<th class="text-center">Menu</th>
</tr>
</thead>
<tbody ng-repeat="position in positions">
<tr>
<th class="warning">{{position.title}}</th>
</tr>
<tr ng-repeat="item in position.items">
<td>{{item.title}}</td>
</tr>
</tbody>
<tfoot>
<tr>
<td class="text-center"
st-pagination=""
st-items-by-page="5"
st-displayed-pages="7">
</td>
</tr>
</tfoot>
</table>
此列表的JSON数据如下:
{
"positions" : [{
"title" : "position 1",
"id" : 1,
"items" : [{
"id" : 1,
"title" : "position 1 - item 1"
}, {
"id" : 2,
"title" : "position 1 - item 2"
}
]
}, {
"title" : "position 2",
"id" : 2,
"items" : [{
"id" : 3,
"title" : "position 2 - item 3"
}
]
}
]
}
表格已经按照我的意愿建立,但分页不起作用,我怀疑它是因为我使用了st-table="positions"
st-table 属性告诉smart-table哪个集合保存您显示的数据,
positions
数组不代表表格的所有行。
谢谢。