Thx Ward.
I wish to back to that sentence :
The controller may expose a binding point which causes the
controller to exercise a service on the view's behalf, e.g. refresh a list
from server data.
Of course the controller does this by calling upon an injected data
service.
My controller would not expose the service itself but rather a
controller method that invokes the data service.
It can become annoying to repeat the same function encapsulating the call
to service for many controllers.
How can we centralize this kind of function ?
Thx
2014-11-23 17:45 GMT+01:00 Ward Bell <[email protected]>:
> Checkout John Papa's Angular style guide which has a lot of traction and
> many approving noises from the Ng team itself:
> https://github.com/johnpapa/angularjs-styleguide
>
> You have learned on this thread the many things you COULD do but, as you
> noted, you are looking for guidance.
>
> I think your principles are good ones and you'll find them in John's guide.
>
> Two notes w/r/t advice given earlier in the thread.
>
> First, I have no quarrel with invoking services in directives and
> controllers after injecting them but I wouldn't code what those services do
> into the controller or directive.
>
> It's a separation of concerns thing. For example, a controller or
> directive should not make calls on the server directly but rather through
> an injected service that performs the task required.
>
> Second, a view should only interact with the controller through a binding.
> The controller may or may not be visible to the view ( it generally is not
> visible when the view and controller at mated by a router).
>
> The controller may expose a binding point which causes the controller to
> exercise a service on the view's behalf, e.g. refresh a list from server
> data. Of course the controller does this by calling upon an injected data
> service. My controller would not expose the service itself but rather a
> controller method that invokes the data service.
>
> The value of all this indirection is
>
> - clear and distinct responsibilities
> - easier testing
> - shorter, easier to maintain components
>
> Remember, I'm giving you recommended practices. You can do what you want.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "AngularJS" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/angular/fIZnAL3sEpo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/d/optout.
>
--
https://plus.google.com/106773736261956794981
http://www.viadeo.com/fr/profile/stephane.labbe3
http://techasite.blogspot.fr/
http://quotitech.blogspot.fr/
https://github.com/asicfr
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.