0

So, here's the problem. I've read you may only inject providers into config - so why is my attempt failing?

angular.module('ionicApp', ['ionic'])

.provider('foo', function()
{
    //
})
.config(function(fooProvider)
{
    //
});

I'm unable to inject my foo provider even when given the Provider suffix - what gives?

Error message:

https://docs.angularjs.org/error/$injector/modulerr?p0=ionicApp&p1=Error:%20%5B$injector:pget%5D%20http:%2F%2Ferrors.angularjs.org%2F1.4.3%2F$injector%2Fpget%3Fp0%3Dtracking%0A%20%20%20%20at%20Error%20(native)%0A%20%20%20%20at%20http:%2F%2Flocalhost:8888%2Flib%2Fionic%2Fjs%2Fionic.bundle.min.js:37:416%0A%20%20%20%20at%20d%20(http:%2F%2Flocalhost:8888%2Flib%2Fionic%2Fjs%2Fionic.bundle.min.js:68:18)%0A%20%20%20%20at%20Object.provider%20(http:%2F%2Flocalhost:8888%2Flib%2Fionic%2Fjs%2Fionic.bundle.min.js:67:436)%0A%20%20%20%20at%20d%20(http:%2F%2Flocalhost:8888%2Flib%2Fionic%2Fjs%2Fionic.bundle.min.js:68:328)%0A%20%20%20%20at%20http:%2F%2Flocalhost:8888%2Flib%2Fionic%2Fjs%2Fionic.bundle.min.js:68:434%0A%20%20%20%20at%20m%20(http:%2F%2Flocalhost:8888%2Flib%2Fionic%2Fjs%2Fionic.bundle.min.js:38:322)%0A%20%20%20%20at%20g%20(http:%2F%2Flocalhost:8888%2Flib%2Fionic%2Fjs%2Fionic.bundle.min.js:68:229)%0A%20%20%20%20at%20eb%20(http:%2F%2Flocalhost:8888%2Flib%2Fionic%2Fjs%2Fionic.bundle.min.js:71:503)%0A%20%20%20%20at%20Ac.d%20(http:%2F%2Flocalhost:8888%2Flib%2Fionic%2Fjs%2Fionic.bundle.min.js:50:339

Any guidance appreciated.

  • I've added the error to the op. –  Jan 06 '16 at 17:06
  • If you look in the [documentation](https://docs.angularjs.org/guide/providers) (under Provider Recipe) in the config call they add the provider as dependency, you do not. – GillesC Jan 06 '16 at 17:09
  • $get method is missing, as are syntactically implemented in all providers – Yerken Jan 06 '16 at 17:12

1 Answers1

2

I guess this error occurs because your provider does not returns a $get function:

.provider("foo", function () {
  return {
    $get: function () {
      // this is mandatory for providers
    }
  };
})

More info:

Community
  • 1
  • 1
sp00m
  • 47,968
  • 31
  • 142
  • 252