I do just that. Under app/ I have a directory for each top-level route. So app/users/users.js contains a declaration of the app.users module, routes and controllers for those routes. app/users also has html templates and all that jazz. I use ui.router, but I don't think that matters much. You don't have to declare all your routes in one block, you can have each submodule just declare its own routes, as long as you do it relative to the parent.
I do have all my controllers and services for a route in that single route.js file, mainly because that way I declare everything associated with that route in one file. Also, most of the controllers are just adding useful objects to the scope and I have encapsulated all my $http service stuff in a separate service that lives outside the /app structure, so everything can get at it. Under /components I put reusable directives with similar structures. /components/userAvatar contains the user-avatar directive (js, scss, html) files, and declares 'app.components.userAvatar'. Then in any of my /app/foo pages, I can use <user-avatar> to display a user. The annoying bit is that when I add a new component or page, I have to add the relevant js in index.html and remember to add the dependency in app.js (and import the scss in main.scss) There's a "best practices for angular app layout" document somewhere in this group that outlines more-or-less this layout. I found that it's really, really useful once the app gets kind of big. e On Wed, Jun 11, 2014 at 11:52 AM, Juan Biscaia <[email protected]> wrote: > Hello everyone, this is my first post in this group and sorry if for some > reason I've made some mistake. > > I've been searching inside this group and all over the internet for a > answer to my question, but can't find any, I don't know if i'm doing the > right question or if this is not a real problem. > I'm about to start the development of a big app in Angular, actualy my > first app in AngularJS+NodeJS. I'm following the angular-seed-app example > to do. Until now i've managed to make my controllers, partials, services > and so on, but i'm kind of stuck in routes, that's because I think that > keeping all the routes of my project inside my app.js file it's just wrong. > > What I want to do is try to put the routes inside the controllers or use > another method to keep the routes for each controller/partial organized > inside folders and files... For example: > > app/ > users/ > usersController.js -> routes goes here... > usersServices.js > usersRoutes.js -> ...or here > directives/ > partials/ > list.html > details.html > > > Cheers. > > -- > 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. > -- 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.
