简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM