Reputation: 703
I have a big app, which contains many layouts and subviews. Looks like (simplified): http://plnkr.co/edit/x4kleCCQH5Hsy6dcjgXe?p=preview
So, I have many directives and services. And only 2-4 simple controllers (10 - 20 lines of code). All logic stored into big directives, which contain many small directives. Am I wrong?
Upvotes: 8
Views: 2502
Reputation: 146
The way I'm approaching it is.
Directives contain view logic, not business logic. This is also where DOM-messing about happens if needed.
Controllers are fairly thin, have minimal business logic.
Angular Services are where most of the heavy lifting is done.
If you have logic that needs to be re-used by multiple areas/controllers or is stateful - it's probably a better fit to put into a Service than a Directive.
Depending on your app/architecture - you could be posting to a server, and having the heavy BL happen on the server side.
The Angular docs have a nice bit on Using Directives Correctly that has a few pointers.
Upvotes: 7
Reputation: 208
The link was busted... a working link to the same guide is here: http://docs.angularjs.org/guide/controller
Upvotes: 0
Reputation: 364727
Sounds good to me.
At some point in the DoubleClick talk, the speaker says something similar to "make controllers as thin as possible."
Upvotes: 0