* 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
()
| 179 | * @returns an unique alpha-numeric string |
| 180 | */ |
| 181 | function nextUid() { |
| 182 | var index = uid.length; |
| 183 | var digit; |
| 184 | |
| 185 | while(index) { |
| 186 | index--; |
| 187 | digit = uid[index].charCodeAt(0); |
| 188 | if (digit == 57 /*'9'*/) { |
| 189 | uid[index] = 'A'; |
| 190 | return uid.join(''); |
| 191 | } |
| 192 | if (digit == 90 /*'Z'*/) { |
| 193 | uid[index] = '0'; |
| 194 | } else { |
| 195 | uid[index] = String.fromCharCode(digit + 1); |
| 196 | return uid.join(''); |
| 197 | } |
| 198 | } |
| 199 | uid.unshift('0'); |
| 200 | return uid.join(''); |
| 201 | } |
| 202 | |
| 203 | |
| 204 | /** |
no test coverage detected