2

I'm lazyloading a feature module inside an Angular Element project.

loadChildren: './crisis-center/crisis-center.module#CrisisCenterModule',

If in my lazy loaded module routes there is a route with component and children all the module route stop working with the error:

No component factory found for CrisisListComponent. Did you add it to @NgModule.entryComponents?

Here you can see a stackblitz of the problem. The test project is forked from this Angular tutorial Stackblitz and the only changes are the one needed for Elements.

I'm missing something or is this an Angular Element bug?

gmazzotti
  • 427
  • 4
  • 11
  • Both the code are same so can you try again either ng build or ng serve – Niraj Apr 17 '19 at 14:04
  • The codes are different. The main difference is in app.module.ts, in the first stackblitz AppComponent is a web-component while in the second one AppComponent is the bootstrapped main component. – gmazzotti Apr 17 '19 at 14:17
  • You are doing wrong like you are using the custom element in the bootstrap component and it will work like dynamic component loading and you expect to load all lazy module load in it. The better solution is to create a custom component and make it as a bootstrap. – Niraj Apr 18 '19 at 06:35
  • Can you provide a small example? Its my first time with elements and I'm dont understand what I should do. – gmazzotti Apr 18 '19 at 07:03
  • But why you want custom element at root level? Are you going to create any custom element as an external component? – Niraj Apr 18 '19 at 07:07

1 Answers1

1

If you want to use custom element as an external component to use in other application then you need to use eager loading modules not lazy that I prefer.

Niraj
  • 775
  • 7
  • 20
  • 1
    I'm not so sure, in the example you can lazy load with the custom element. If the lazy module has only 1 level or if the parent level is a componentless route it works. My problem is lazyloading route with children. – gmazzotti Apr 18 '19 at 15:07
  • Yes that is my concern as well, I already asked the question related to that but very few can understand that's why I get downvote :) here is my question https://stackoverflow.com/questions/55742273/can-i-create-custom-element-of-the-application-with-lazy-loading-modules If you can upvote that so anyone expert can answer on it – Niraj Apr 19 '19 at 05:43
  • Thanks for the support! you can refer this link and try if you get success on it https://www.softwarearchitekt.at/post/2018/07/29/angular-elements-part-ii-lazy-and-external-web-components.aspx – Niraj Apr 19 '19 at 07:00