I see #2 mentioned a lot and I don't understand why it is a problem. You can still organize your code in the modular way like #1 points out. What is the real benefit of putting all your views/services/directives/controllers in their own angular modules? Is it for reusing code across applications?
We currently have a large angular/django site and we take a lot of lessons from the modularity of django and it works wonders. I think people are too caught up is the way that either the tutorials or yeoman creates things for them and they don't think.
I'm not that familiar with django, can you expand a bit? I thought it took a rails-like approach and had separate folders for views/controllers etc. Are you following something similar for angular or are you doing small ui modules like the article suggested?
My original question was more about the folks who do something like have one top level app and then inject all these minimodules like this:
Django is usually comprised of "apps" within your large web application, and each of those "apps" are self-contained modules with views, models, "controllers"... We try to mirror this in Angular and it has worked out pretty well. In our app, we have a main app.js which pulls in all of our "modules" and each module then contains the controllers, services, and models. For example:
/* app.js */
var app = angular.module('app', ['module1', module2', ...])
Then each module has an __init__.js file which will further inject the services, controllers and directives.
Excuse me if there are some slight errors in my above examples as we use coffeescript at work and haven't written Angular code in javascript in some time.
Hope that clears up my comment a little, and let me know if there are any other questions or comments! Thanks!
Yeah, I guess that's part of the beauty (lol) of angular - it's low-level and unopinionated enough that people from different paradigms and frameworks can organize it in ways that make sense to them. The rails guys do it one way, the python folks do it another, php people do it another way, and no one can figure what the haskell people are doing.
I'd like to see some data on if/how splitting an app into multiple modules affects performance. I'm guessing it might help with testing performance but I really have no clue.
3
u/[deleted] Oct 04 '14
I see #2 mentioned a lot and I don't understand why it is a problem. You can still organize your code in the modular way like #1 points out. What is the real benefit of putting all your views/services/directives/controllers in their own angular modules? Is it for reusing code across applications?