Is there any thing exist which I could do in service but not in factory or vice-versa? Basically I want to conclude the difference between the service and a factory.
-
Welcome to SO. Please take a look on this http://stackoverflow.com/tour – Eduard Uta Apr 12 '16 at 08:11
-
5Possible duplicate of [AngularJS: Service vs provider vs factory](http://stackoverflow.com/questions/15666048/angularjs-service-vs-provider-vs-factory) – Saad Bin Shahid Apr 12 '16 at 08:12
-
Please Google before posting a question, Have a look at top 3 results at Google ; http://stackoverflow.com/questions/13762228/confused-about-service-vs-factory, http://stackoverflow.com/questions/13762228/confused-about-service-vs-factory, http://blog.thoughtram.io/angular/2015/07/07/service-vs-factory-once-and-for-all.html. Thanks. – Saad Bin Shahid Apr 12 '16 at 08:14
1 Answers
you can take a look at a the new post .service() versus .factory(), the actual answer. by @ToddMotto
So, what is a service?
A Service is just a function for the business layer of the application, it’s just a simple function. It acts as a constructor function and is invoked once at runtime with new, much like you would with plain JavaScript
Factory
Next, the confusing
.factory()
method. A factory is not just “another way” for doing services, anyone that tells you that is wrong. It can however, give you the same capabilities of a.service()
, but is much more powerful and flexible.A factory is not just a “way” of returning something, a factory is in fact a design pattern. Factories create Objects, that’s it. Now ask yourself: what type of Object do I want? With
.factory()
, we can create various Objects, such as new Class instances (with.prototype
or ES2015 Classes), return Object literals, return functions and closures, or even just return a simply String. You can create whatever you like, that’s the rule.
Enjoy

- 11
- 2