Angular elements routing issue

508 views
Skip to first unread message

Nishi Ajmera

unread,
Sep 27, 2019, 1:56:59 PM9/27/19
to Angular and AngularJS discussion
Hi 

I have two angular applications(parent, child). I am creating a custom element (using angular elements) from the child application and injecting it into the parent application. The child application has two forms. First form routes to the second one on button click. 

The issue that I am facing is with the routing of the child application which is explained below with the example.

Parent application calls the child application on button click (button - custom element) through the .js file.


MainApp.PNG

HTML below the custom element button is from the child application


ChildApp called.PNG


First time when i click test, it navigates to Form2


Form2rendered.PNG


If I click custom element again, it navigates to the Form1 but the route on click of test button (route to form2) stops working. If you see the link gets changed but the Form doesn't get rendered.


ChildApp called.PNG


Form2NavgationIssue.PNG


Please help.



Sander Elias

unread,
Oct 1, 2019, 10:53:44 AM10/1/19
to Angular and AngularJS discussion
Hi Nishi,

I'm fairly sure the router can't be active in multiple applications in the same page. Move your routing to a single app, and use angular elements inside the routes that should come from the other app.

Regards
Sander 

Nishi Ajmera

unread,
Oct 7, 2019, 5:17:34 AM10/7/19
to Angular and AngularJS discussion
Hi Sander, 

Thanks for the reply. The routes work when i navigate from a different component to the elements component. It is only when i try to navigate within the same component it stop working. 
What i have noticed is when the component gets destroyed completely and then created again, everything works fine.

Thanks
Nishi
Reply all
Reply to author
Forward
0 new messages