Angularjs: factory vs service, and extend
Blogs20142014-12-21
Angularjs: factory vs service
AngularJS Factory and Service is easy to distinguish and write.
-
Factory:
Factory can be treated as a object object = {}: so Object.create(), object property/method are available.
-
Service:
Service can be treated as Function, function Service(){}: so prototype, this, apply(parent, arguments) are available.
The following is my demo to use both of them. It would be great to extend factory/service based on pure JavaScript object/function inheritance. http://jsfiddle.net/williamjxj/1srnfcgw/4/embedded/
