Angular Lazy-loaded Modules sharing internal flows

60 Views Asked by At

I am developing an application which is using ion-tabs and im trying to share some specific internal flow [NgModule at the moment] from feature_2 with feature_1. This would look something like this. In feature_1 i have a button, when i click that button, i launch a flow from feature_2, but i stay on tab1. Whenever i click back from that page i just launched I'm back on tab_1. The problem Im facing is that whenever i try to navigate from app/tabs/tabs1 to app/tabs/tab2/some_internal_page i switch tabs and that path app/tabs/tab2/some_internal_page becomes the landing path of app/tabs/tab2 instead of its intended page.

The example routes are:

path: 'tabs',
component: TabsPage,
children: [

  {
    path: 'tab1',
    loadChildren : () => ...Module1
  },
  {
    path: 'tab2',
    loadChildren : () => ...Module2
  }
]

Where the modules themselves have their own internal routes. Example for tab1 when Module1 is loaded:

path: '',
component: LandingPage,
children: [

  {
    path: 'internal',
    loadChildren : () => ...Module3
  },
  {
    path: 'internal_two',
    loadChildren : () => ...Module4
  }
]

Some things i tried:

  1. Using ion-nav and exposing a specific flow using a service from a feature module. Where that service using a modalController launches some specific component. This is kinda tedious because i have to manage my own nav stack, i can't use router to navigate etc.
  2. I tried using an external path such as app/modal, which would mimic the features that are under app/tabs/. This helps with the navigation but because of lazy-loading im obviously having separate instances of the services required for that specific feature. (I can remove the services from providers and user providedIn: 'root') but that sounds overkill since all features need to make everything available as root even if required only for that specific feature module?

Is there a way for me to share internal NgModules of features lazy loaded within ion-tabs flow with any other feature? Navigate though their flows but stay on the current tab and once done be able to navigate back?

0

There are 0 best solutions below