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

时间:2013-05-26 12:24:39

标签: angularjs

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

1 个答案:

答案 0 :(得分:17)

对于提供者,值将注入$ get函数。

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

   };
});

此处有更多详情:

  1. AngularJS: Service vs provider vs factory

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

相关问题