Including NgModules conditionally

128 Views Asked by At

I am upgrading an Angular 1.5 application to Angular 2.

In our app, we decided that each 'feature' should have it's own Angular 1 module.

However, some users don't get every feature. We control that via flags before Angular bootstrap.

so we would do something like this:

let deps = [ 'myDep', 'myOtherDep' ]
if (flags.useThirdDep) {
  deps.push('thirdDep')
}
angular.module('myApp', deps);

Where each of those 'deps' are other Angular 1 modules.

Does Angular 2 have a mechanism for this? Would it work with AoT? I know of lazy loading but that is only on routes I thought?

Thanks! Joe

0

There are 0 best solutions below