根据角度范围值动态更改分页页面大小
Dynamically change Pagination page size from angular scope value
我试图允许用户更改要显示的表中的行数。该网络应用程序适用于所有类型的设备,因此用户需要能够选择要显示的行数,以最大限度地减少滚动。
这是javascript模型
$scope.pageSizes = [
{ size: 10},
{ size: 25, isSelected: true },
{ size: 50}
];
HTML代码。这是我的页面大小选择器。
<li ng-repeat="pageSize in pageSizes">
<a href="javascript:void(0)" ng-click="changePageSize(pageSize.size)"><span ng-class="{ orange: pageSize.isSelected }">{{pageSize.size}}</span></a>
</li>
和同一HTML文件中的表。
<table st-table="users" st-safe-src="safeUsers" class="table-striped argus-table">
<thead>
<tr>
<th st-sort="id" class="sortable min-width">Id</th>
<th st-sort="username" class="sortable">Username</th>
<th st-sort="email" class="sortable">Email</th>
<th class="table-action-header"></th>
<th class="table-action-header"></th>
<th class="table-action-header"></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="user in users">
<td>ID</td>
<td>Username</td>
<td>Email</td>
<td>Option 1</td>
<td>Option 2</td>
<td>Option 3</td>
</tr>
</tbody>
<tfoot>
<tr>
<td class="text-center" st-pagination="" st-items-by-page="25" colspan="6"></td>
</tr>
</tfoot>
</table>
st-items-by-page="25"
是我认为我必须放置角度代码的地方。
我尝试使用范围函数来查找新选择的
$scope.changePageSize = function (pageSize) {
$scope.filter.pageSize = pageSize;
_.find($scope.pageSizes, function (page) {
if (page === pageSize) {
$scope.selectedPageSize = page.size;
page.isSelected = true;
}
else
page.isSelected = false;
});
};
和页脚再次
<tfoot>
<tr>
<td class="text-center" st-pagination="" st-items-by-page="{{selectedPageSize}}" colspan="6"></td>
</tr>
</tfoot>
然而,这会导致错误
Error: [$parse:syntax] Syntax Error: Token '{' invalid key at column 2 of the expression [{{getSelectedPageSize}}] starting at [{getSelectedPageSize}}].
如有任何帮助,我们将不胜感激。感谢
不要使用模板表示法({{scopeValue}}
)为每页提供项目,只需提供一个解析为$scope
上的值的表达式
这个
st-items-by-page="{{selectedPageSize}}"
应该像这个
st-items-by-page="selectedPageSize"
文档
相关文章:
- 目录和动态分页PHP
- 根据角度范围值动态更改分页页面大小
- 谷歌图表与动态数据和分页是可能的
- angularjs html中动态表的分页
- AngularJS 服务器端排序与分页 - 动态值
- jQuery 分页与动态
- .
- 分页动态加载的 Webix 树节点
- 在包含来自 JSON 的动态条目的表中进行分页
- 分页表的动态索引
- 可脚分页在动态数据轨道上不起作用
- 使用余烬的动态分页
- angularjs不显示动态搜索结果的分页
- 使用Nightmare/Electron动态分页(分页)
- 在弹出窗口中分页和网页抓取的CasperJS步骤的动态数量
- 动态检查文本是否转到下一页,并使用pdfmake在pdf中添加分页符
- 动态分页
- 动态插入分页符
- 动态Angular表没有分页过滤
- 为什么引导动态表分页不能工作
- 如何在进行自定义分页时动态应用类