I have an Ionic application with a List Page Module and a Subdir Page Module underneath the Page module. Here is the folder structure ---> list/subdir.
Problem: I have the problem of List page module always loading when I navigate to localhost:8100/list/subdir instead of the Subdir page loading.
Outcome: I want the Subdir page to load when I navigate to localhost:8100/list/subdir; but instead it loads List page. I only want to load List page when URL is localhost:8100/list
app.routing.module.ts
import { NgModule } from '@angular/core';
import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
const routes: Routes = [
{
path: '',
redirectTo: 'home',
pathMatch: 'full'
},
{
path: 'home',
loadChildren: './home/home.module#HomePageModule'
},
{
path: 'list',
loadChildren: './list/list.module#ListPageModule'
}
];
@NgModule({
imports: [
RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
],
exports: [RouterModule]
})
export class AppRoutingModule {}
list.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { RouterModule } from '@angular/router';
import { ListPage } from './list.page';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
RouterModule.forChild([
{
path: '',
component: ListPage,
children: [
{
path: 'subdir',
loadChildren: './subdir/subdir.module#SubdirPageModule',
}
]
}
])
],
declarations: [ListPage]
})
export class ListPageModule {}

