News for hackers. Stuff that matters.
Re:AngularJS Tutorial: Learn to Build Modern Web Apps by davidwparker on Wednesday September 04, 2013 @03:33PM (#6329874)
Working with a large Angular app, I've found it much nicer to split away from the "Rails"-style convention of grouping by type (controllers, models, etc) and instead grouping by modules. This plays especially well with Angular where you can group everything within a module together and include a single module which ties all the dependencies together.

Curious if others do something similar and group code together by modules or does everyone group by type?

Re:AngularJS Tutorial: Learn to Build Modern Web Apps by Rodeoclash on Wednesday September 04, 2013 @07:28PM (#6331202)
Can you give an example of how you've organised the modules? Like one per model (a products module) or by section of the site?
Re:AngularJS Tutorial: Learn to Build Modern Web Apps by rs on Wednesday September 04, 2013 @08:01PM (#6331335)
If I'm not mistaken, instead of splitting into:

  controllers/
    users.js
    teams.js
  models/
    user.js
    team.js
Just have:

  modules/
    users.js
    teams.js
Where model and controllers for each function is defined within a single file.

I've switched to this convention as well - less context switching of files.

Re:AngularJS Tutorial: Learn to Build Modern Web Apps by Kiro on Thursday September 05, 2013 @04:16AM (#6332829)
I don't understand what you would have in "models". Services?
Re:AngularJS Tutorial: Learn to Build Modern Web Apps by p3rs3us on Wednesday September 04, 2013 @04:59PM (#6330450)
I recently spent days writing AngularJS app and I came to same conclusion that I should have split the app into modules. Even though the style of grouping together Controllers and Services works well, it still won't be easy to maintain when the size of app grows big.
Re:AngularJS Tutorial: Learn to Build Modern Web Apps by joevandyk on Wednesday September 04, 2013 @08:14PM (#6331388)
I like grouping by functionality. All the account-related code in one directory, all the order-related code in another, etc.

Bugs me to have the order logic spread out in the views, models, controllers, hepers, libs, etc folders.

Re:AngularJS Tutorial: Learn to Build Modern Web Apps by babby on Wednesday September 04, 2013 @07:31PM (#6331223)
I'm always excited to structure my projects in a different more effective way - well, it's more of a struggle - anyway, this sounds interesting. Can someone elaborate on the file structure and structure of files and the way they connect?

I'm rolling with a MVP structure that frankly is becoming cumbersome with my current project's size.

Re:AngularJS Tutorial: Learn to Build Modern Web Apps by tegeek on Thursday September 05, 2013 @05:30AM (#6333035)
What I've done myself and found it pretty scalable is as follows:

appShell/ views/allbaseviewshere viewmodels/controllers or viewmodels for the core views services/baseservices moduels/ account /views/ /viewmodels/ /services/ order /views/ /viewmodels/ /services/ /controllers/ static /css/ /js/ /images/

AppShell contains the app starter page, controllers and util services (showing popups, utility functions etc.) AppShell/Views contains all the UI Skelton for the app (bootstrap main page, etc)

Every folder inside "modules" contains views, controllers (viewmodels) and services belongs to only that module. Account folder contains views for user registeration, sign in, change user profile, etc. etc.

This way you can keep building new moduels in their respective folders without touching the frozen code (already built modules).

Each module talk to outside world using "services". No module can touch anything belongs to other modules but with "services".

Re:AngularJS Tutorial: Learn to Build Modern Web Apps by mac1175 on Wednesday September 04, 2013 @10:54PM (#6331919)
I do it the way you just mentioned. I create specific modules and have them inject their dependencies. Each modules I create has its one or more models within its domain. I was going to go the repository route (one module per type) but it seemed overkill.
Re:AngularJS Tutorial: Learn to Build Modern Web Apps by t0mas88 on Wednesday September 04, 2013 @03:40PM (#6329927)
For front-end such as Angular I always group in modules, usually nested modules for larger apps. For back-end systems sometimes type makes more sense, especially when the app grows quite big and uses a layered architecture.
Re:AngularJS Tutorial: Learn to Build Modern Web Apps by ganarajpr on Wednesday September 04, 2013 @03:41PM (#6329934)
I do the same as you. Group by Module - which in my humble opinion is the real intention of the modules.

Oh between I do group by Type inside of a module.

Re:AngularJS Tutorial: Learn to Build Modern Web Apps by glazskunrukitis on Wednesday September 04, 2013 @04:28PM (#6330250)
Why not both?