Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat(pagination): add ngDisabled support for the pager
- Add `ngDisabled` support to the pager component
  • Loading branch information
wesleycho committed Aug 17, 2015
commit a3bacb2f14f975cdc395e74fcc28c3c12b2a60e9
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>