Skip to content

Lazy loading angular.strap components #86

@vlad-nica

Description

@vlad-nica

Hi,

How can I lazy load components of a module like angular.strap if the module declares its components as dependencies:

angular.module('mgcrea.ngStrap', [
  'mgcrea.ngStrap.modal',
  'mgcrea.ngStrap.aside',
  'mgcrea.ngStrap.alert',
  'mgcrea.ngStrap.button',
  'mgcrea.ngStrap.select',
  'mgcrea.ngStrap.datepicker',
  'mgcrea.ngStrap.timepicker',
  'mgcrea.ngStrap.navbar',
  'mgcrea.ngStrap.tooltip',
  'mgcrea.ngStrap.popover',
  'mgcrea.ngStrap.dropdown',
  'mgcrea.ngStrap.typeahead',
  'mgcrea.ngStrap.scrollspy',
  'mgcrea.ngStrap.affix',
  'mgcrea.ngStrap.tab',
  'mgcrea.ngStrap.collapse'
]);

If I leave the module defined like above, the app fails to instantiate:

Error: [$injector:modulerr] Failed to instantiate module angularPoC due to:
Error: [$injector:modulerr] Failed to instantiate module oc.lazyLoad due to:
Error: [$injector:nomod] Module 'mgcrea.ngStrap.modal' is not available!

If I remove the dependencies, they load but not compile.

I have a feeling that the only solution is to rewrite all the components so that they all link to same module (e.g.: instead of
angular.module('mgcrea.ngStrap.typeahead').provider('$typeahead') the provider should be directly defined in angular.module('mgcrea.ngStrap)) but please tell me I'm wrong... :)
So, is there any possibility to lazy load the entire module or parts of it without having to intervene in angular.strap components' code?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions