Angular.JS File Naming Conventions

661 views
Skip to first unread message

Almog

unread,
Sep 23, 2012, 5:28:54 PM9/23/12
to ang...@googlegroups.com
Are there any specific file naming conventions for Angular.JS? 
Javascript is pretty up to the user I have used camelCase and dash before. 

Thinking of using the Rails underscore convention but wonder if it matters for Angular. 

Thanks,
Almog   

Alex Ross

unread,
Sep 24, 2012, 10:30:06 PM9/24/12
to ang...@googlegroups.com
Most Javascript frameworks/file conventions that I've seen use all lowercase and dashes (see YUI as an example). There's no autoloading in AngularJS (that I'm aware of), so like you mentioned it's up to you.

The current general convention I'm following when I have an intensively OO project w/ complex data structures is to have a structure like this:

/[webroot]
    /js
        /app
            app.js
            controllers.js
            directives.js
            filters.js
            services.js
        /document
            entity.js
            entity-type-2.js
        /lib
            /angular
                [angular lib files]
            /angular-ui
                [angular-ui lib files]
            /[another lib]

If I have to further modularize I'll break up the /app directory into sub-directories rather than files, i.e. a "services" directory rather than a services.js file.

Almog

unread,
Sep 26, 2012, 2:51:15 PM9/26/12
to ang...@googlegroups.com
Thanks this is exactly what I'm doing and breaking everything up into sub I don't like the idea of having a services.js file with to many many resource calls. 

Alex Ross

unread,
Sep 27, 2012, 6:37:11 AM9/27/12
to ang...@googlegroups.com
Yeah, absolutely... a /services type directory (or multiple of them according to function) under the main app directory would fit in nicely with many server-side MVC frameworks as well, which is probably the best source of inspiration for structure when your angular app grows beyond simple CRUD.
Reply all
Reply to author
Forward
0 new messages