Created
March 31, 2014 19:39
-
-
Save amcdnl/9900479 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simplifies duplicating `define` definitions for `angular.module`. | |
* | |
* For example: | |
* | |
* define(['app/module1', 'app/module2'], function(module1, module2){ | |
* var module3 = angular.module('app.module3', ['app.module1', 'app.module2']); | |
* // your code | |
* return module3; | |
* }); | |
* | |
* instead `moduleDefine` translates the module name's for you like: | |
* | |
* define(['app/module1', 'app/module2'], function(module1, module2){ | |
* var module3 = angular.moduleDefine('app.module3', arguments); | |
* return module3; | |
* }); | |
* | |
* NOTE: This only works if in your module definitions if you return the module | |
* at the end of the definition. | |
* | |
*/ | |
angular.moduleDefine = function(name, args){ | |
var modules = Array.slice(args) | |
.filter(function (m) { return m && m.name; }) | |
.map(function (mm) { return mm.name }); | |
return angular.module(name, modules); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment