I divide everything into separate systems. I have a top-level package that
does two things:

1) It requires all the packages I want to include or sub-packages I have
defined.

angular.module('app', ['ng', 'app.stuff', 'app.otherstuff',
'app.otherstuff.substuff', 'randomPackageFromGithub'])

2) It defines a / route on ui-router.

All my components are separate modules, all my "page"-level routes are
modules (it's a SPA, but I have separate modules for things like #/users
and #/groups and so forth). I set it up more or less like the linked google
doc, as my project is quite large and reasonably modular, so I like having
that separation. Incidentally, I also stuck scss files in those modules,
but there I have to do a manual include into my main.scss style page, b/c
sass isn't smart enough to figure it out otherwise.

This means most of my directives are defined in a submodule as well. I try
to prefix all my application-specific stuff with my app prefix, but then I
leave my more generic directives unprefixed. I'm thinking: someday I may
get around to sharing that select widget on github, as it's pretty useful
and simple, but the doodad that I use to render a user avatar is too
app-specific to think about sharing.

It's also handy that ui-router can be configured in stages, so there's no
problem with putting .state declarations on multiple modules, and they all
seem to just take care of substates and nesting properly without any fuss.

In my submodules, It doesn't seem that I have to declare dependencies - I
can do angular.module('app.otherstuff', ['ng']) and still inject an object
I declared in app.stuff. I'm not sure if this is intended behavior or not,
but I noticed it when I started forgetting to add that. I also assume that
this may only work on modules that are child.modules of my main app. module.

That said, I do my level best to actually declare those dependencies in
that array, even if it doesn't seem to do much, because (a) it's a good
place to keep track of them and (b) that way I can pull out a single module
and know what it needs to take with it. Also, (c) I don't like it when
route-level components require other route-level components, so this
generates a good smell for me to notice. It's fine if there's a route that
relies on a directive, but directives should probably be self-contained and
routes shouldn't rely on each other.

e


On Sun, Jul 6, 2014 at 9:58 PM, Sander Elias <[email protected]> wrote:

> Hi Joberto,
>
> What about a module called itaas.global, that you include wherever you
> need it?
> In my own systems I don't divide everything in separate modules. I write
> them in
> such a way that it is easy to separate them when needed, but keep the
> project
> in 1 big module.
> When I'm writing parts that are clearly meant to be reusable, I put those
> in their
> own module. (utility stuff, your own house-styled pop-ups and so on)
>
> Regards
> Sander
>
> --
> 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.

Reply via email to