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

Commit

Permalink
feat(pagination): add ngDisabled support for the pager
Browse files Browse the repository at this point in the history
- Add `ngDisabled` support to the pager component

Closes #4217
Resolves #2856
  • Loading branch information
wesleycho committed Aug 17, 2015
1 parent 0b03a01 commit ba734b4
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/pagination/docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,7 @@ For `ng-model`, `total-items`, `items-per-page` and `num-pages` see pagination s
* `template-url`
_(Default: 'template/pagination/pager.html') :
Override the template for the component with a custom provided template

* `ng-disabled` <i class="glyphicon glyphicon-eye-open"></i>
:
Used to disable the pager component
3 changes: 2 additions & 1 deletion src/pagination/pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ angular.module('ui.bootstrap.pagination', [])
scope: {
totalItems: '=',
previousText: '@',
nextText: '@'
nextText: '@',
ngDisabled: '='
},
require: ['pager', '?ngModel'],
controller: 'PaginationController',
Expand Down
22 changes: 22 additions & 0 deletions src/pagination/test/pager.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,26 @@ describe('pager directive', function() {
});
});

it('disables the component when ng-disabled is true', function() {
$rootScope.disable = true;

element = $compile('<pager total-items="total" ng-disabled="disable" ng-model="currentPage"></pager>')($rootScope);
$rootScope.$digest();
updateCurrentPage(2);

expect(getPaginationEl(0)).toHaveClass('disabled');
expect(getPaginationEl(-1)).toHaveClass('disabled');

$rootScope.disable = false;
$rootScope.$digest();

expect(getPaginationEl(0)).not.toHaveClass('disabled');
expect(getPaginationEl(-1)).not.toHaveClass('disabled');

$rootScope.disable = true;
$rootScope.$digest();

expect(getPaginationEl(0)).toHaveClass('disabled');
expect(getPaginationEl(-1)).toHaveClass('disabled');
});
});
6 changes: 3 additions & 3 deletions template/pagination/pager.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ul class="pager">
<li ng-class="{disabled: noPrevious(), previous: align}"><a href ng-click="selectPage(page - 1, $event)">{{::getText('previous')}}</a></li>
<li ng-class="{disabled: noNext(), next: align}"><a href ng-click="selectPage(page + 1, $event)">{{::getText('next')}}</a></li>
</ul>
<li ng-class="{disabled: noPrevious()||ngDisabled, previous: align}"><a href ng-click="selectPage(page - 1, $event)">{{::getText('previous')}}</a></li>
<li ng-class="{disabled: noNext()||ngDisabled, next: align}"><a href ng-click="selectPage(page + 1, $event)">{{::getText('next')}}</a></li>
</ul>

0 comments on commit ba734b4

Please sign in to comment.