【发布时间】:2016-10-03 05:44:16
【问题描述】:
目前我有这个代码。
<tr dir-paginate="person in People | filter:q
| orderBy:sortKey:reverse| itemsPerPage: criteria.pagesize"
current-page="currentPage" pagination-id="PeoplePagination">
我的问题是如何在控制器上使用角度目录分页时获取过滤数组的计数。
在 dirPagination.tpl.html 的指令模板 url 上,下面的代码提供了价值。
<div class="range-label">Displaying {{ range.lower }} -
{{ range.upper }} of {{ range.total }}</div>
我的问题是如果我把它放在我的主控制器上,我如何获得 {{range.total}}。
更新:
范围位于 dir-pagination 指令上
link: function dirPaginationControlsLinkFn(scope, element, attrs) {
// rawId is the un-interpolated value of the pagination-id attribute. This is only important when the corresponding dir-paginate directive has
// not yet been linked (e.g. if it is inside an ng-if block), and in that case it prevents this controls directive from assuming that there is
// no corresponding dir-paginate directive and wrongly throwing an exception.
var rawId = attrs.paginationId || DEFAULT_ID;
var paginationId = scope.paginationId || attrs.paginationId || DEFAULT_ID;
if (!paginationService.isRegistered(paginationId) && !paginationService.isRegistered(rawId)) {
var idMessage = (paginationId !== DEFAULT_ID) ? ' (id: ' + paginationId + ') ' : ' ';
throw 'pagination directive: the pagination controls' + idMessage + 'cannot be used without the corresponding pagination directive.';
}
if (!scope.maxSize) { scope.maxSize = 9; }
scope.directionLinks = angular.isDefined(attrs.directionLinks) ? scope.$parent.$eval(attrs.directionLinks) : true;
scope.boundaryLinks = angular.isDefined(attrs.boundaryLinks) ? scope.$parent.$eval(attrs.boundaryLinks) : false;
var paginationRange = Math.max(scope.maxSize, 5);
scope.pages = [];
scope.pagination = {
last: 1,
current: 1
};
scope.range = {
lower: 1,
upper: 1,
total: 1
};
基本上我想要的是当用户在搜索框中输入内容时获取当前数组大小的值。
【问题讨论】:
-
您能提供一个完整的代码示例吗?真的很难理解你想要做什么......(例如范围是什么?)
-
能否请您提供您的代码在plunker或请提供主控制器的代码sn-p