Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using `$q.defer()` within angular's provider

Tags:

angularjs

Is there a way to inject $q into provider, in my case, angular throws exception telling that there is no such provider.

like image 735
Lu4 Avatar asked May 26 '13 12:05

Lu4


1 Answers

For a provider, the values are injected in the $get function.

myApp.provider('testProvider', function() {
   this.$get = function($q) {

   };
});

More details here:

  1. AngularJS: Service vs provider vs factory

  2. https://gist.github.com/Mithrandir0x/3639232

like image 174
LostInComputer Avatar answered Nov 19 '22 10:11

LostInComputer