@@ -18,7 +18,7 @@ angular.module('bw.paging', []).directive('paging', function () {
1818 * Feel free to tweak / fork values for your application
1919 */
2020 var regex = / \{ p a g e \} / g;
21-
21+
2222
2323 /**
2424 * The angular return value required for the directive
@@ -31,7 +31,7 @@ angular.module('bw.paging', []).directive('paging', function () {
3131
3232 // Assign the angular link function
3333 link : fieldLink ,
34-
34+
3535 // Assign the angular directive template HTML
3636 template : fieldTemplate ,
3737
@@ -62,7 +62,7 @@ angular.module('bw.paging', []).directive('paging', function () {
6262 textTitleNext : '@' ,
6363 textTitlePrev : '@'
6464 }
65-
65+
6666 } ;
6767
6868
@@ -80,12 +80,12 @@ angular.module('bw.paging', []).directive('paging', function () {
8080 build ( scope , attrs ) ;
8181 } ) ;
8282 }
83-
84-
83+
84+
8585 /**
86- * Create our template html
86+ * Create our template html
8787 * We use a function to figure out how to handle href correctly
88- *
88+ *
8989 * @param {object } el - Angular link element
9090 * @param {object } attrs - Angular link attribute
9191 */
@@ -94,12 +94,13 @@ angular.module('bw.paging', []).directive('paging', function () {
9494 '<li ' +
9595 'title="{{Item.title}}" ' +
9696 'data-ng-class="Item.liClass" ' +
97- 'data-ng-repeat="Item in List"> ' +
97+ 'data-ng-repeat="Item in List track by $index "> ' +
9898 '<a ' +
9999 ( attrs . pgHref ? 'data-ng-href="{{Item.pgHref}}" ' : 'href ' ) +
100100 'data-ng-class="Item.aClass" ' +
101101 'data-ng-click="Item.action()" ' +
102- 'data-ng-bind="Item.value">' +
102+ 'data-ng-bind="Item.value"' +
103+ 'ng-attr-id="$first || $last ? $index : undefined">'
103104 '</a> ' +
104105 '</li>' +
105106 '</ul>'
@@ -117,14 +118,14 @@ angular.module('bw.paging', []).directive('paging', function () {
117118
118119 scope . List = [ ] ;
119120 scope . Hide = false ;
120-
121+
121122 scope . page = parseInt ( scope . page ) || 1 ;
122123 scope . total = parseInt ( scope . total ) || 0 ;
123124 scope . adjacent = parseInt ( scope . adjacent ) || 2 ;
124125
125126 scope . pgHref = scope . pgHref || '' ;
126127 scope . dots = scope . dots || '...' ;
127-
128+
128129 scope . ulClass = scope . ulClass || 'pagination' ;
129130 scope . activeClass = scope . activeClass || 'active' ;
130131 scope . disabledClass = scope . disabledClass || 'disabled' ;
@@ -133,17 +134,17 @@ angular.module('bw.paging', []).directive('paging', function () {
133134 scope . textLast = scope . textLast || '>>' ;
134135 scope . textNext = scope . textNext || '>' ;
135136 scope . textPrev = scope . textPrev || '<' ;
136-
137+
137138 scope . textFirstClass = scope . textFirstClass || '' ;
138139 scope . textLastClass = scope . textLastClass || '' ;
139140 scope . textNextClass = scope . textNextClass || '' ;
140141 scope . textPrevClass = scope . textPrevClass || '' ;
141142
142143 scope . textTitlePage = scope . textTitlePage || 'Page {page}' ;
143- scope . textTitleFirst = scope . textTitleFirst || 'First Page' ;
144- scope . textTitleLast = scope . textTitleLast || 'Last Page' ;
145- scope . textTitleNext = scope . textTitleNext || 'Next Page' ;
146- scope . textTitlePrev = scope . textTitlePrev || 'Previous Page' ;
144+ scope . textTitleFirst = scope . textTitleFirst || 'First Page' ;
145+ scope . textTitleLast = scope . textTitleLast || 'Last Page' ;
146+ scope . textTitleNext = scope . textTitleNext || 'Next Page' ;
147+ scope . textTitlePrev = scope . textTitlePrev || 'Previous Page' ;
147148
148149 scope . hideIfEmpty = evalBoolAttribute ( scope , attrs . hideIfEmpty ) ;
149150 scope . showPrevNext = evalBoolAttribute ( scope , attrs . showPrevNext ) ;
@@ -156,7 +157,7 @@ angular.module('bw.paging', []).directive('paging', function () {
156157 /**
157158 * A helper to perform our boolean eval on attributes
158159 * This allows flexibility in the attribute for strings and variables in scope
159- *
160+ *
160161 * @param {Object } scope - The local directive scope object
161162 * @param {Object } value - The attribute value of interest
162163 */
@@ -212,7 +213,7 @@ angular.module('bw.paging', []).directive('paging', function () {
212213 return ;
213214 }
214215
215- // Block if we are forcing disabled
216+ // Block if we are forcing disabled
216217 if ( scope . isDisabled )
217218 {
218219 return ;
@@ -266,19 +267,19 @@ angular.module('bw.paging', []).directive('paging', function () {
266267 if ( scope . showFirstLast ) {
267268 alpha = {
268269 value : scope . textFirst ,
269- title : scope . textTitleFirst ,
270+ title : scope . textTitleFirst ,
270271 aClass : scope . textFirstClass ,
271272 page : 1
272- } ;
273+ } ;
273274 }
274275
275276 if ( scope . showPrevNext ) {
276277 beta = {
277278 value : scope . textPrev ,
278- title : scope . textTitlePrev ,
279+ title : scope . textTitlePrev ,
279280 aClass : scope . textPrevClass ,
280281 page : prevPage
281- } ;
282+ } ;
282283 }
283284
284285 } else {
@@ -289,21 +290,21 @@ angular.module('bw.paging', []).directive('paging', function () {
289290 if ( scope . showPrevNext ) {
290291 alpha = {
291292 value : scope . textNext ,
292- title : scope . textTitleNext ,
293+ title : scope . textTitleNext ,
293294 aClass : scope . textNextClass ,
294295 page : nextPage
295- } ;
296+ } ;
296297 }
297-
298+
298299 if ( scope . showFirstLast ) {
299300 beta = {
300301 value : scope . textLast ,
301- title : scope . textTitleLast ,
302+ title : scope . textTitleLast ,
302303 aClass : scope . textLastClass ,
303304 page : pageCount
304- } ;
305+ } ;
305306 }
306-
307+
307308 }
308309
309310 // Create the Add Item Function
@@ -319,7 +320,7 @@ angular.module('bw.paging', []).directive('paging', function () {
319320 internalAction ( scope , item . page ) ;
320321 }
321322 }
322- } ;
323+ } ;
323324 } ;
324325
325326 // Force disabled if specified
@@ -330,13 +331,13 @@ angular.module('bw.paging', []).directive('paging', function () {
330331 // Add alpha items
331332 if ( alpha ) {
332333 var alphaItem = buildItem ( alpha , disabled ) ;
333- scope . List . push ( alphaItem ) ;
334+ scope . List . push ( alphaItem ) ;
334335 }
335-
336+
336337 // Add beta items
337338 if ( beta ) {
338339 var betaItem = buildItem ( beta , disabled ) ;
339- scope . List . push ( betaItem ) ;
340+ scope . List . push ( betaItem ) ;
340341 }
341342 }
342343
@@ -350,13 +351,13 @@ angular.module('bw.paging', []).directive('paging', function () {
350351 * @param {Object } scope - The local directive scope object
351352 */
352353 function addRange ( start , finish , scope ) {
353-
354+
354355 // Add our items where i is the page number
355356 var i = 0 ;
356357 for ( i = start ; i <= finish ; i ++ ) {
357358
358359 var pgHref = scope . pgHref . replace ( regex , i ) ;
359- var liClass = scope . page == i ? scope . activeClass : '' ;
360+ var liClass = scope . page == i ? scope . activeClass : '' ;
360361
361362 // Handle items that are affected by disabled
362363 if ( scope . isDisabled ) {
0 commit comments