Hi there,
It’s been a while I didn’t try Ionic, and now I try to understand some logic about ionic 4 + Angular.
I generated a sample with “Folder” (split-view) with the console wizard, and I’m facing a misunderstood. There is a FolderPageRoutingModule
with a single Route (default to FolderPage
).
Ionic generates the Folder part as a “module”
OK, why not, but now, I wonder this: instead of changing app-routing.module.ts
, is there a way to use folder/folder-routing.module.ts
to set routes to a component ?
What I mean is that, at this time, the generated app is very clean but it only pass the page “id” to the FolderPage. IMHO it’s a bit complicated to understand the good practice to create a new component and say “OK, for this route, in the “folder” module, I want to use this component instead”.
If “folder” is a module, the routes should be managed by the module. But…
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { ExampleComponent } from './example/example.component';
import { FolderPage } from './folder.page';
const routes: Routes = [
{
path: 'Outbox',
component: ExampleComponent,
},
{
path: '',
component: FolderPage,
},
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class FolderPageRoutingModule {}
This does nothing when I go to “/fodler/Outbox”.
Of course, if I do this in App routing, it works, but that’s not the right way.
Could anyone help me to understand the good practice here ? Thanks a lot
1 post - 1 participant