Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit ba734b4

Browse files
committed
feat(pagination): add ngDisabled support for the pager
- Add `ngDisabled` support to the pager component Closes #4217 Resolves #2856
1 parent 0b03a01 commit ba734b4

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

src/pagination/docs/readme.md

+4
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,7 @@ For `ng-model`, `total-items`, `items-per-page` and `num-pages` see pagination s
8585
* `template-url`
8686
_(Default: 'template/pagination/pager.html') :
8787
Override the template for the component with a custom provided template
88+
89+
* `ng-disabled` <i class="glyphicon glyphicon-eye-open"></i>
90+
:
91+
Used to disable the pager component

src/pagination/pagination.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ angular.module('ui.bootstrap.pagination', [])
207207
scope: {
208208
totalItems: '=',
209209
previousText: '@',
210-
nextText: '@'
210+
nextText: '@',
211+
ngDisabled: '='
211212
},
212213
require: ['pager', '?ngModel'],
213214
controller: 'PaginationController',

src/pagination/test/pager.spec.js

+22
Original file line numberDiff line numberDiff line change
@@ -256,4 +256,26 @@ describe('pager directive', function() {
256256
});
257257
});
258258

259+
it('disables the component when ng-disabled is true', function() {
260+
$rootScope.disable = true;
261+
262+
element = $compile('<pager total-items="total" ng-disabled="disable" ng-model="currentPage"></pager>')($rootScope);
263+
$rootScope.$digest();
264+
updateCurrentPage(2);
265+
266+
expect(getPaginationEl(0)).toHaveClass('disabled');
267+
expect(getPaginationEl(-1)).toHaveClass('disabled');
268+
269+
$rootScope.disable = false;
270+
$rootScope.$digest();
271+
272+
expect(getPaginationEl(0)).not.toHaveClass('disabled');
273+
expect(getPaginationEl(-1)).not.toHaveClass('disabled');
274+
275+
$rootScope.disable = true;
276+
$rootScope.$digest();
277+
278+
expect(getPaginationEl(0)).toHaveClass('disabled');
279+
expect(getPaginationEl(-1)).toHaveClass('disabled');
280+
});
259281
});

template/pagination/pager.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<ul class="pager">
2-
<li ng-class="{disabled: noPrevious(), previous: align}"><a href ng-click="selectPage(page - 1, $event)">{{::getText('previous')}}</a></li>
3-
<li ng-class="{disabled: noNext(), next: align}"><a href ng-click="selectPage(page + 1, $event)">{{::getText('next')}}</a></li>
4-
</ul>
2+
<li ng-class="{disabled: noPrevious()||ngDisabled, previous: align}"><a href ng-click="selectPage(page - 1, $event)">{{::getText('previous')}}</a></li>
3+
<li ng-class="{disabled: noNext()||ngDisabled, next: align}"><a href ng-click="selectPage(page + 1, $event)">{{::getText('next')}}</a></li>
4+
</ul>

0 commit comments

Comments
 (0)