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

Service and Factory #3

Open
anything963 opened this issue Jul 18, 2017 · 0 comments
Open

Service and Factory #3

anything963 opened this issue Jul 18, 2017 · 0 comments

Comments

@anything963
Copy link

anything963 commented Jul 18, 2017

I'm a little confused after reading your post here:

From AngularJS docs

AngularJS services are:
Singletons – Each component dependent on a service gets a reference to the single instance generated by the service factory.

My confusion is, if they are singletons why do you instantiate them using 'new' keyword? My understanding was you could just include them as dependency and use the service methods, just like $http.

And factory, as the name implies, is responsible for creating instances of objects and you would use 'new' to instantiate those objects.

Am I missing something here? Is there a concept I'm failing to understand here?

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