brunob15 / ngx-element

Angular Element that allows lazy loading Angular components in non-angular applications
33 stars 5 forks source link

Routing only works via RouterLink #24

Closed afalz closed 4 years ago

afalz commented 4 years ago

I'm trying to use routing inside a lazy loaded module. The routing works when using a RouterLink but when loading directly to the route eg. http://localhost:4200/talk-first - the component is not shown as expected. I've attached an example which demonstrates the problem.

Am I doing something wrong or is this an issue? routing.zip

brunob15 commented 4 years ago

Hi! Thanks for your question. I think it's more like a known issue with routing and custom elements.

I suggest you take a look at the following links: https://medium.com/@timon.grassl/how-to-use-routing-in-angular-web-components-c6a76449cdb https://github.com/angular/angular/issues/23740

And here I just pushed a solution to the example you shared: https://github.com/brunob15/angular-talk-first-test

I made changes in files talk-routing.module.ts, talk.component.ts and talk.component.html.

Hope it helps.

afalz commented 4 years ago

Thanks Bruno, that solves the issue!