12

I'm new to Angular and looking for info on how to lazy-load (or dynamically load?) some widget components into my page. All of the info I'm finding on lazying loading has to do with Angular router. Router is not what I need in this case, so it's hard to find info on how to do this specifically.

What I have is a site that has numerous widgets that can load on a page. It is configurable, so the user can define which widgets to show on each page, and there can be any number of them. Some of these widgets could theoretically be pretty heavy, so I don't want to load them at site launch.

I will also need to pass a string to initialize some or all of these widgets.

So how do I go about lazy (dynamic?) loading components/modules into my Angular app?

BBaysinger
  • 6,614
  • 13
  • 63
  • 132
  • 1
    as far as I know you can only lazy load modules, with components in them, not components themselves. so I suppose you could put each component into a module and lazy load that module. Otherwise, you are better off with some *ngIf statement on each component... – FussinHussin Sep 27 '17 at 16:18
  • unfortunately I don't know how to do that, but, you could use the router and route to the same page with a different url to load specific modules, kind of a hack but it would work – FussinHussin Oct 02 '17 at 22:42

0 Answers0