Services and Factories are just syntax sugar on top of Providers, most times you won't need the full power of a Provider, so a Service is a name for a Provider with the commonly-needed defaults provided. Usually you won't need Providers, but they are there when you are doing something really weird.
From the docs: "The most verbose, but also the most comprehensive one is a Provider recipe. The remaining four recipe types — Value, Factory, Service and Constant — are just syntactic sugar on top of a provider recipe." https://code.angularjs.org/1.2.16/docs/guide/providers
I was reading through this and thinking "holy crap these angularJS guys are missing the entire point." They are running a damn app-server inside the browser page, for the love of god!
Well, I'm missing it - what exactly is "the point"? When building client side applications that have hundreds of components and must be able to function in a stand-alone mode robustly, potentially over multiple user sessions, until a network connection becomes available, having access to a robust implementation of proven, testable software development patterns makes sense to me. It did when I was building those client-side apps in Java or .NET, what changes now I am building them in the language with wider reach than any other in history? All of a sudden I should approach it like a script kiddy?
Building a client side application that has hundreds of components and be able to function in a stand-alone mode robustly, potentially over multiple user sessions, until a network connection becomes available, having access to a robust implementation of proven, testable software development patterns:
- Objective C
- Java + Android
- Monad and #C
Why are we killing ourselves with browsers? I mean, to a degree I get the cross platform deal... but unless you are building for exactly that environment (ie NOT A WEB APPLICATION) then it doesn't make sense to me... at all. There are better tools.
The Angular guys aren't missing the point. I think it's the other way around.
People see the word "Factory" and for some reason assume that it's somehow a Java enterprise bloatware feature. Nevermind that "Factories" Angular are
a) Nothing at all like Factories in Java
b) Something you don't need to use, and most Angular apps likely don't
c) Really useful when you do need them
If AngularJS is too heavyweight for what you're trying to achieve, it's not he right tool for your task. It's like complaining that a forklift isn't a very good hammer.
Angular is used to build thick heavyweight client applications. The sort of thing you might use to build a complete desktop-style application in the browser running in offline mode.
Mind you it's still surprisingly good at smaller applications as well. But if your solution can be solved with a few lines of jQuery, then you don't need Angular.
Funnily enough I'm working on a web application and I have used angular on a few pages and intercooler elsewhere. I really like intercooler but it's not even close to being able to tackle the parts that I used angular for.
And that's not to say I love angular - it was just the least worst option available with the requisite power and flexibility at any level of maturity.
Yeah, I'm being doctrinare here, but as I say on the main page:
Intercooler is a little library built to play well with other web technologies, like AngularJS, EmberJS and Turbolinks. Use the right tool for the particular job: Intercooler won't get in the way.
From what I see out there, thought, there are a lot of apps that could be done with something simple like intercooler (e.g. Stripe) that are using complicated MVC frameworks.
Services and Factories are just syntax sugar on top of Providers, most times you won't need the full power of a Provider, so a Service is a name for a Provider with the commonly-needed defaults provided. Usually you won't need Providers, but they are there when you are doing something really weird.
From the docs: "The most verbose, but also the most comprehensive one is a Provider recipe. The remaining four recipe types — Value, Factory, Service and Constant — are just syntactic sugar on top of a provider recipe." https://code.angularjs.org/1.2.16/docs/guide/providers