AngularJS: controller vs service

后端 未结 4 2202
-上瘾入骨i
-上瘾入骨i 2020-12-13 02:16

I have read a couple of posts regarding proper usage of angularjs entities: services, factories, controllers and directives.

My particular concern is a comparison of

4条回答
  •  情深已故
    2020-12-13 02:48

    controllers - responsibilities: initialize the view, mediate interaction between view/scope and services. It has dependencies on the view and model, but is more concerned with the view and making it work.

    services - responsibilities: provides business services that is not dependent on the view or the controller. Its primary concern is delivering services, regardless of the consumer (controller/view/other services).

    I'm not convinced if persistence factors into the differences.

提交回复
热议问题