什么是工厂,角js服务?他们之间有什么区别?什么时候使用它们? [英] what is factory,service in angular js? what are the difference between them? when to use them?
本文介绍了什么是工厂,角js服务?他们之间有什么区别?什么时候使用它们?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
请帮帮我!由于我是棱角分明的新手,我无法理解工厂和服务的用途是什么?
-它们之间有什么不同?
- 何时使用它们?
- 哪个更好用?
谢谢。
hello guys,
please help me! As i am new to angular js i could not understand what is the use of factory and service?
-what is the different between them?
- when to use of them?
- which is better to use?
thank you.
推荐答案
即使我对AngularJS太新了。
但是你可以做的新技术就是充分利用像GOOGLE这样的搜索引擎。
查看这些谷歌搜索 -
- 在angularjs中使用工厂和服务 [ ^ ]
- angularjs中的工厂和服务之间的区别 [ ^ ]
- 何时使用它们? - 可以在与第一个相同的搜索中找到
- 哪个更好用? - 你根据第二次搜索的结果决定
希望,它有助于:)
Even I am too new to AngularJS.
But what you can do as new to a technology is make good use of search engines like GOOGLE.
Check out these google searches-
- use of factory and service in angularjs[^]
- difference between factory and service in angularjs[^]
- when to use of them? --can be found in the same search as the first one
- which is better to use? --you decide based on the results of second search
Hope, it helps :)
从我的理解(和看看它们的构建方式)功能是相同的,但它们的用途不同。我函数返回一个对象或实例。这类似于普通类。服务更像是一个没有实例化的静态类。
我可以像工厂一样使用工厂,你可以像工厂那样使用服务没有任何实际差异。我想这更像是一个标记,所以你可以跟踪哪个是。
我希望有所帮助^ _ ^
地狱,我希望是对的:S
Andy
from what I understand (and looking at the ways they are built up) there function is identical but their uses differ. I function returns an object or instance. This is analogous to a common class. A service is more like a static class that does not get instantiated.
I can use a factory like a service and you can use a service like a factory so there really isn't any actual difference. I guess it's more of a marker so you can keep track of which is which.
I hope that helps ^_^
Hell, I hope that's right :S
Andy
这篇关于什么是工厂,角js服务?他们之间有什么区别?什么时候使用它们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文