在代币我有这个代码。如何获得dir分页过滤结果的数组数目?
<tr dir-paginate="person in People | filter:q
| orderBy:sortKey:reverse| itemsPerPage: criteria.pagesize"
current-page="currentPage" pagination-id="PeoplePagination">
我的问题是如何在控制器上使用angular dir-pagination时得到过滤数组的计数。
上的指令模板网址是dirPagination.tpl.html下面的代码提供了值。
<div class="range-label">Displaying {{ range.lower }} -
{{ range.upper }} of {{ range.total }}</div>
我的问题是我怎么得到{{range.total}}如果我把这个我的主控制器上。
UPDATE:
范围位于DIR-分页指令
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
};
基本上我想要的是获取当前数组大小的值时,用户在搜索框上输入内容。
你能提供一个完整的代码示例?这是真的很难理解你正在尝试做什么...(例如什么是范围?) – nagyf
你可以请你提供你的代码在一个笨蛋或请提供主控制器的代码片段 – Vikash
可能的重复[如何显示长度过滤ng-repeat数据](http://stackoverflow.com/questions/15316363/how-to-display-length-of-filtered-ng-repeat-data) – Aides