mgechev / angularjs-style-guide

📚 Community-driven set of best practices for AngularJS application development

Home Page:https://mgechev.github.io/angularjs-style-guide/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

services and scope

dylang opened this issue · comments

Do you have a suggestion for services that need to read and modify the scope?

For example:

  • Pass in the scope and change it in the service.
  • Pass in the scope and use the output of the service to change the scope in the controller.
  • Extract out data needed for the service from the scope and only pass that data to the service instead of the whole scope, then update the scope in the controller using the results of the service.

Thanks!

I don't think that modification of the scope by a service is a good idea. Passing single parameters sounds reasonable and useful but making changes to the whole scope doesn't sounds like a good practice to me.

The last option sounds best to me. I think it could be included in the Services section.