I might need to investigate why I'm sharing code between Angular and other objects in my page. Fair enough. But in the meantime:
I've got a bit of code that creates IDs. It's in an Angular service:
angular.module("Gamma.services").service "idService", () ->
@newId = ->
id = String.fromCharCode(Math.floor(Math.random() * 25) + 65) +
((@someNumber + Math.floor(Math.random() * 1e15) +
new Date().getMilliseconds()).toString(36)).toUpperCase()
OK so that's nifty and all, but I need to share this little chunk of code with some non-Angular code in my app. I've got a solution to it (moved this code into a function off of the window object), but I think the more-correct solution might be to pass a function pointer that points to the Angular service.
How can I pass an Angular service to non-Angular code?