Search code examples
javascriptangularjsangularjs-module

Angular module dependency


is possible I start my angular module without some dependency?

it's my angular.module

angular.module("app", [
'ngSanitize', 'ngAnimate', 'ui.router', 'ngMaterial',
'ngRoute', 'ngCookies', 'NgSwitchery',
'ngCkeditor', 'angularFileUpload',
]);

I would like not use, they're required on 1st. loading. 'NgSwitchery', 'ngCkeditor', 'angularFileUpload'

Thank you.


Solution

  • yes, you could use condition to pass dependency.

    var dependencyArray = ['dep1', 'dep2'];
    if (someCondition) {
        dependencyArray = ['dep1', 'dep2', 'dep3', 'dep4'];
    }
    
      angular.module('app',dependencyArray); 
    

    You might need requireJS if you're trying to load them at different times.