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

Commit 4629071

Browse files
just-borispkozlowski-opensource
authored andcommitted
feat(pagination): add opportunity to localize pagination without template rewrite
1 parent c386744 commit 4629071

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

src/pagination/pagination.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ angular.module('ui.bootstrap.pagination', [])
77
numPages: '=',
88
currentPage: '=',
99
maxSize: '=',
10-
onSelectPage: '&'
10+
onSelectPage: '&',
11+
nextText: '@',
12+
previousText: '@'
1113
},
1214
templateUrl: 'template/pagination/pagination.html',
1315
replace: true,

src/pagination/test/pagination.spec.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,24 @@ describe('pagination directive with max size option', function () {
190190
expect($rootScope.maxSize).toBe(15);
191191
});
192192

193-
});
193+
});
194+
195+
describe('pagination custom', function () {
196+
var $rootScope, element;
197+
beforeEach(module('ui.bootstrap.pagination'));
198+
beforeEach(module('template/pagination/pagination.html'));
199+
beforeEach(inject(function(_$compile_, _$rootScope_) {
200+
$compile = _$compile_;
201+
$rootScope = _$rootScope_;
202+
$rootScope.numPages = 5;
203+
$rootScope.currentPage = 3;
204+
element = $compile('<pagination previous-text="<<" next-text=">>" num-pages="numPages" current-page="currentPage"></pagination>')($rootScope);
205+
$rootScope.$digest();
206+
}));
207+
208+
it('should change paging text from attribute', function () {
209+
expect(element.find('li').eq(0).text()).toBe('<<');
210+
expect(element.find('li').eq(-1).text()).toBe('>>');
211+
});
212+
213+
});

template/pagination/pagination.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="pagination"><ul>
2-
<li ng-class="{disabled: noPrevious()}"><a ng-click="selectPrevious()">Previous</a></li>
2+
<li ng-class="{disabled: noPrevious()}"><a ng-click="selectPrevious()">{{previousText || 'Previous'}}</a></li>
33
<li ng-repeat="page in pages" ng-class="{active: isActive(page)}"><a ng-click="selectPage(page)">{{page}}</a></li>
4-
<li ng-class="{disabled: noNext()}"><a ng-click="selectNext()">Next</a></li>
4+
<li ng-class="{disabled: noNext()}"><a ng-click="selectNext()">{{nextText || 'Next'}}</a></li>
55
</ul>
66
</div>

0 commit comments

Comments
 (0)