-
Notifications
You must be signed in to change notification settings - Fork 903
Conventions
Zan Thrash edited this page Aug 13, 2015
·
22 revisions
##Style Guide Use Todd Mottos Angular Style Guide as a starting point
##Webpack Conventions With the introduction of webpack to the deck application we now have 2 module systems in play:
- The angular module system which is used for Dependency Injection(DI).
- The CommonsJS style that is used for file system level dependency resolution.
These 2 systems play nicely together as long as you follow a few conventions.
###Export Angular Module Name Any module that needs to be injected via angular needs to export (CommonsJS style) the name of the module.
File name: my.service.js
'use strict';
module.exports = angular
.module('my.module.service', [])
.factory('myService', function() {
// service stuff
})
.name; // <-- This returns the name of the module ('my.module.service') for Angular Dependency Injection.
We can require this CommonsJS style module by it’s relative path file name as an Angular dependency in another module.
'use strict';
module.exports = angular
.module('my.controller.module', [
require('./my.service.js') //<- require by relative file path
])
.controller('myController', function (‘myService’) { //<- Angular DI
//controller stuff
})
.name;