Skip to content

Instantly share code, notes, and snippets.

@leog
Created July 12, 2015 23:44
Show Gist options
  • Save leog/6fabdf15190f4ae24533 to your computer and use it in GitHub Desktop.
Save leog/6fabdf15190f4ae24533 to your computer and use it in GitHub Desktop.
Very simple RequireJS modules defining AngularJS modules exporting their own module name
define(['angular'], function(angular) {
var settings = { moduleName: 'first' };
angular
.module(settings.moduleName, [])
.filter('greet', function() {
return function(name) {
return 'Hello, ' + name + '!';
}
});
return settings;
});
define(['angular', 'firstModule'], function(angular, first) {
angular
.module('second', [dependency.moduleName])
.filter('goodbye', function() {
return function(name) {
return 'Good bye, ' + name + '!';
}
});
});
@kewwwa
Copy link

kewwwa commented Jan 25, 2016

If think there is a mistake on line 3 in secondModule.
It should be [first.moduleName] rather than [dependency.moduleName].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment