As mentioned here provider, service, and factory are the same things. In fact so is value() and constant(). They are all specialized more succinct versions of provider. You can see it broken down in this image:
<http://www.simplygoodcode.com/wp-content/uploads/2015/11/angularjs-provider-service-factory-highlight.png> Choosing comes down to which one results in you accomplishing what you want in the last amount of code. And the additional question of whether you want to be able to access the provider during the configuration phase. I break it down in more detail on at: http://www.simplygoodcode.com/2015/11/the-difference-between-service-provider-and-factory-in-angularjs/ On Friday, April 24, 2015 at 3:11:53 AM UTC-4, Ovi Wan-Kenobi wrote: > > thanks, this was helpful to me > I have put together a demo app which is showing the use of most angular > concepts > https://github.com/oviwankenobi/AngularJSTodoList#angularjstodolist > > > On Friday, 17 August 2012 20:00:53 UTC+2, Ben Clinkinbeard wrote: >> >> In order to get this straight in my own head I have created a very simple >> demo which can be viewed at http://jsbin.com/ohamub/1/edit >> >> There are comments in the code illustrating the primary differences but I >> will expand on them a bit here. As a note, I am just getting my head around >> this so if I say anything that is wrong please let me know. >> >> *Services* >> Syntax: module.service( 'serviceName', function ); >> Result: When declaring serviceName as an injectable argument *you will >> be provided the actual function reference* passed to module.service. >> Usage: Could be useful for sharing utility functions that are useful to >> invoke by simply appending () to the injected function reference. Could >> also be run with injectedArg.call( this ) or similar. >> >> *Factories* >> Syntax: module.factory( 'factoryName', function ); >> Result: When declaring factoryName as an injectable argument *you will >> be provided the value that is returned by invoking the function reference* >> passed to module.factory. >> Usage: Could be useful for returning a 'class' function that can then be >> new'ed to create instances. >> >> *Providers* >> Syntax: module.provider( 'providerName', function ); >> Result: When declaring providerName as an injectable argument *you will >> be provided the value that is returned by invoking the $get method of the >> function reference* passed to module.provider. >> Usage: Could be useful for returning a 'class' function that can then be >> new'ed to create instances but that requires some sort of configuration >> before being injected. Perhaps useful for classes that are reusable across >> projects? Still kind of hazy on this one. >> >> Again, please let me know if I have misspoken here, but hopefully this is >> accurate and will prove useful to somebody. >> >> Ben >> > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
