注射服务到angularJS其他服务 [英] Injecting a service into another service in angularJS
本文介绍了注射服务到angularJS其他服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可能注入一个服务到另一个angularJS服务?
Is it possible to inject one service into another service in angularJS?
推荐答案
是的。按照angularjs定期注射规则。
Yes. follow the regular injection rule in angularjs.
app.service('service1', function(){});
//Inject service1 into service2
app.service('service2',function(service1){});
感谢@simon。这是更好地利用阵列注入,以避免缩小文件的问题。
Thanks to @simon. It is better to use Array injection to avoid minifying problem.
app.service('service2',['service1', function(service1) {}]);
这篇关于注射服务到angularJS其他服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文