* A consistent way of creating unique IDs in angular. The ID is a sequence of alpha numeric * characters such as '012ABC'. The reason why we are not using simply a number counter is that * the number string gets longer over time, and it can also overflow, where as the nextId * will grow much slow
()
| 374 | * @returns {string} an unique alpha-numeric string |
| 375 | */ |
| 376 | function nextUid() { |
| 377 | var index = uid.length; |
| 378 | var digit; |
| 379 | |
| 380 | while(index) { |
| 381 | index--; |
| 382 | digit = uid[index].charCodeAt(0); |
| 383 | if (digit == 57 /*'9'*/) { |
| 384 | uid[index] = 'A'; |
| 385 | return uid.join(''); |
| 386 | } |
| 387 | if (digit == 90 /*'Z'*/) { |
| 388 | uid[index] = '0'; |
| 389 | } else { |
| 390 | uid[index] = String.fromCharCode(digit + 1); |
| 391 | return uid.join(''); |
| 392 | } |
| 393 | } |
| 394 | uid.unshift('0'); |
| 395 | return uid.join(''); |
| 396 | } |
| 397 | |
| 398 | |
| 399 | /** |
no outgoing calls
no test coverage detected