AngularJS

Angular: Dependency Injection with Providers

Error message:

Uncaught Error: [$injector:modulerr] Failed to instantiate module x due to:
Error: [$injector:modulerr] Failed to instantiate module x due to:
Error: [$injector:unpr] Unknown provider: xx


This got me. It appeared to be working with all other DIs, but not this specific one. What’s wrong?

app.provider 'mdParse', (markdown) ->

After deleting and comparing, it turns out, providers have unique ways of injecting dependencies. Their dependencies should be injected within the parameter of $get method. As in:

app.provider 'mdParse', () ->
  ...
  @$get = (markdown) -> new Parse()
  return
Standard