在angular的提供者中使用`$ q.defer()`

Lu4*_*Lu4 8 angularjs

有没有办法向提供者注入$ q,在我的情况下,角度抛出异常告诉没有这样的提供者.

Los*_*ter 17

对于提供者,值将在$ get函数中注入.

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

   };
});
Run Code Online (Sandbox Code Playgroud)

更多细节在这里:

  1. AngularJS:服务与提供商vs工厂

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

  • @ Lu4我假设你已经找到了你的答案,但对于这里的Google员工; 是的,这是可能的.`$ get:['$ q',函数($ q){})]` (6认同)
  • 是否可以使用minification-safe方式声明$ get函数?(即`['$ q',函数($ q){...}]`) (2认同)