在代幣我有這個代碼。如何獲得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