search

Home  >  Q&A  >  body text

angular.js - angularJs中service,factory,controller之间的区别及适用场景?

angularJs新手
请问angularJs中service,factory,controller之间的区别是什么,他们分别适用于什么地方?

漂亮男人漂亮男人2744 days ago720

reply all(1)I'll reply

  • 为情所困

    为情所困2017-05-15 16:55:20

    Controller focuses on business scenarios, that is, serving specific scenarios, so do not reuse controllers. It is recommended to divide controllers in a small range and use parent-child scopes to meet business scenarios.

    factory provides some public methods and functions, it is recommended to abstract and reuse factory.

    Service is similar to factory. It will be instantiated and can save data. It is used as a communication tool between controllers and is recommended for reuse.

    reply
    0
  • Cancelreply