How to load module based on a configuration file in angularJS

Viewed 554

I have several defined modules. I don't want to load them all into my App. Instead, I want to load them based on a configuration file. For example

Module1:

angular.module('section1', [])

Module2:

angular.module('section2', [])

In each of the module, it will have its own HTML template and business logic. Then in the app.module.js:

angular.module('app', ['module1', 'module2']);

module1 and module2 will both be loaded together. I don't want to hard code it, instead, I will have a configuration file, something like:

[{'module1': true}, {'module2':false}]

Eventually, every time when the app is launched, I read the configuration file and then decide which modules will be loaded and which modules will not. In above example, module1 will be loaded while module 2 will not.

How can I do that?

2 Answers
Related