Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difference bet Service and Factory #2

Open
2 tasks
mpatel3 opened this issue Aug 25, 2016 · 0 comments
Open
2 tasks

Difference bet Service and Factory #2

mpatel3 opened this issue Aug 25, 2016 · 0 comments

Comments

@mpatel3
Copy link

mpatel3 commented Aug 25, 2016

confusion between Service and Factory.

Whatever you have explained on your website ( service vs factory vs provider) is best . Still i have one issue.

  1. I have created object inside the angular.module('name',[]).service() and return the object in that service. still my code is working. Usually we are creating an object in factory and returning that object. but for service i have try to do same thing. still it is working.
  2. I understand concept of new() and this of service and returning of object for factory. Both support scoping.
  • So,
  • i am confused why we have factory and service both ? both are doing the same thing.
  • What advantages will i get when i use factory or service ? Does factory have any advantage over service or service have on factory? or both are just the way to create Angular Services.

I have searched on internet read answers but not able to find the concrete answer. if you guys can explain it will be good.

Here is the JSFiddle Code i have created. You can go there and run the code.

Demo Angular Service vs Factory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant