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

Reply via email to