angularruntime

Can I load modules on runtime? Angular 2


I have basic angular app with links. By clicking the link, user download Angular 2 module with all dependencies (typescript files or compiled js files, choose one to make it work).

After download is finished, this basic app injects the module and starts it (assume we have specified entry point for such downloaded modules).

It sounds pretty much the same as a plugin system, but in web and during current session only. Can I somehow achieve this in Angular 2?


Solution

  • You can lazy load any module with angular-router

    { path: 'lazy', loadChildren: 'lazy/lazy.module#LazyModule' }