• Blogs (9)
    • πŸ“± 236 - 992 - 3846

      πŸ“§ jxjwilliam@gmail.com

    • Version: β€πŸš€ 1.1.0
  • Angularjs: factory vs service, and extend

    Blogs20142014-12-21


    Angularjs: factory vs service

    AngularJS Factory and Service is easy to distinguish and write.

    1. Factory:

      Factory can be treated as a object object = {}: so Object.create(), object property/method are available.

    2. 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/