siddii / angular-timer

re-usable/inter-operable AngularJS timer directive ⛺
http://siddii.github.io/angular-timer/
MIT License
792 stars 939 forks source link

Wrap code in closure? #182

Open qria opened 9 years ago

qria commented 9 years ago

Had my main module named 'app', loaded this module, and literally everything broke.

I solved it by wrapping everything except timerModule part in closure. (I excluded timerModule because I wasn't sure it wouldn't break anything)

Maybe wrap everything possible in to a closure?

I know, I probably shouldn't have named my app 'app', but still, I think it'll be better to not use root namespace as much as we can.

prasad47 commented 9 years ago

var ApplicationConfiguration = (function() { // Init module configuration options var applicationModuleName = 'app'; var applicationModuleVendorDependencies = ['ngResource', 'ngAnimate', 'ui.router', 'ui.bootstrap', 'ui.utils','timer'];

// Add a new vertical module
var registerModule = function(moduleName, dependencies) {
    // Create angular module
    angular.module(moduleName, dependencies || []);

    // Add the module to the AngularJS configuration file
    angular.module(applicationModuleName).requires.push(moduleName);
};

return {
    applicationModuleName: applicationModuleName,
    applicationModuleVendorDependencies: applicationModuleVendorDependencies,
    registerModule: registerModule
};

})(); You Could Register Module like the above . Or you may Inject the time Module directly in your Controllers