如何在AngularJS中進(jìn)行尋呼?我有一個(gè)內(nèi)存中大約有1000個(gè)項(xiàng)的數(shù)據(jù)集,并且試圖為這個(gè)數(shù)據(jù)集創(chuàng)建一個(gè)尋呼機(jī),但是我不確定如何做到這一點(diǎn)。我正在使用一個(gè)自定義的過濾器函數(shù)來過濾結(jié)果,這很好,但不知怎么的,我需要得到頁數(shù)。有什么線索嗎?
3 回答

慕仙森
TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超8個(gè)贊
角UI引導(dǎo)-分頁指令
檢查UI引導(dǎo)氏分頁指令..我最終使用了它,而不是這里發(fā)布的內(nèi)容,因?yàn)樗凶銐虻奶匦詠頋M足我當(dāng)前的使用,并且有一個(gè)徹底測(cè)試規(guī)范陪著它。
視點(diǎn)
<!--?table?here?--><pagination? ??ng-model="currentPage" ??total-items="todos.length" ??max-size="maxSize"?? ??boundary-links="true"></pagination><!--?items/page?select?here?if?you?like?-->
控制器
todos.controller("TodoController",?function($scope)?{ ???$scope.filteredTodos?=?[] ??,$scope.currentPage?=?1 ??,$scope.numPerPage?=?10 ??,$scope.maxSize?=?5; ??$scope.makeTodos?=?function()?{ ????$scope.todos?=?[]; ????for?(i=1;i<=1000;i++)?{ ??????$scope.todos.push({?text:"todo?"+i,?done:false}); ????} ??}; ??$scope.makeTodos();? ??$scope.$watch("currentPage?+?numPerPage",?function()?{ ????var?begin?=?(($scope.currentPage?-?1)?*?$scope.numPerPage) ????,?end?=?begin?+?$scope.numPerPage; ????$scope.filteredTodos?=?$scope.todos.slice(begin,?end); ??});});
遺留版本:
視點(diǎn)
<!--?table?here?--><div?data-pagination=""?data-num-pages="numPages()"? ??data-current-page="currentPage"?data-max-size="maxSize"?? ??data-boundary-links="true"></div><!--?items/page?select?here?if?you?like?-->
控制器
todos.controller("TodoController",?function($scope)?{ ???$scope.filteredTodos?=?[] ??,$scope.currentPage?=?1 ??,$scope.numPerPage?=?10 ??,$scope.maxSize?=?5; ??$scope.makeTodos?=?function()?{ ????$scope.todos?=?[]; ????for?(i=1;i<=1000;i++)?{ ??????$scope.todos.push({?text:"todo?"+i,?done:false}); ????} ??}; ??$scope.makeTodos();? ??$scope.numPages?=?function?()?{ ????return?Math.ceil($scope.todos.length?/?$scope.numPerPage); ??}; ??$scope.$watch("currentPage?+?numPerPage",?function()?{ ????var?begin?=?(($scope.currentPage?-?1)?*?$scope.numPerPage) ????,?end?=?begin?+?$scope.numPerPage; ????$scope.filteredTodos?=?$scope.todos.slice(begin,?end); ??});});
- 3 回答
- 0 關(guān)注
- 545 瀏覽
添加回答
舉報(bào)
0/150
提交
取消