Ian McNally

TIL $injector

May 12, 2014

I’d been programmatically injecting dependencies in an angular app by creating a new injector instance:

$injector = angular.injector [moduleName]

But it turns out you can inject $injector, your module’s instance of angular.injector, and call it as you normally would:

app.service 'myService', ($injector) ->
    $injector.get 'someinjection'

Ian McNally

Hey, I'm Ian. I build websites and write about what I learn as I go. Follow me on Twitter.