Hello everyone, thanks for the time you spend reading and helping.
I’m trying to reproduce the tab app from the Ionic CLI so I can learn about routing. I first wanted do it without modules and with routing in a single file, app-routing.module.ts
To do that I’ve created 4 components with Ionic CLI like this:
- tabs component which has ion-tab in its template (parent)
- home tab component (nested)
- agenda tab component (nested)
- about tab component (nested)
File structure looks like that :
my app-routing.module.ts looks like :
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './tabs/home/home.component';
import { AgendaComponent } from './tabs/agenda/agenda.component';
import { AboutComponent } from './tabs/about/about.component';
import { TabsComponent } from './tabs/tabs.component';
const routes: Routes = [
{ path: '', redirectTo: 'tabs', pathMatch: 'full' },
{ path: 'tabs', component: TabsComponent, children: [
{
path: 'home',
component: HomeComponent,
outlet: 'outlet_home',
},
{
path: 'agenda',
component: AgendaComponent,
outlet: 'outlet_agenda',
},
{
path: 'about',
component: AboutComponent,
outlet: 'outlet_about',
},
]
},
];
@NgModule({
imports: [RouterModule.forRoot(routes, { enableTracing: true })],
exports: [RouterModule]
})
export class AppRoutingModule { }
my tabs.component.html (parent template) looks like:
<ion-tabs>
<ion-tab label="home" icon="musical-note">
<ion-router-outlet name="outlet_home"></ion-router-outlet>
</ion-tab>
<ion-tab label="agenda" icon="person">
<ion-router-outlet name="outlet_agenda"></ion-router-outlet>
</ion-tab>
<ion-tab label="about" icon="people">
<ion-router-outlet name="outlet_about"></ion-router-outlet>
</ion-tab>
</ion-tabs>
Childs component only got basic templates and default component.ts from the CLI.
My main tab component loads well, I can see the tab component but when I try to access a child’s url let’s say http://localhost:8100/tabs/home I can see this error in the chrome console :
I doesn’t understand why it doesn’t match any route as I have defined one in app-routing.module.ts
Any insights or help would be greatly appreciated as I’m going crazy on this
Also I can’t determine if this is a framework issue as I read some stuff about angular not handling outlet on root level or if it’s me misusing those tools.
Environment specs :
Ionic:
ionic (Ionic CLI) : 4.1.1
Ionic Framework : @ionic/angular 4.0.0-beta.3
@angular-devkit/core : 0.7.4
@angular-devkit/schematics : 0.7.4
@angular/cli : 6.1.4
@ionic/ng-toolkit : 1.0.7
@ionic/schematics-angular : 1.0.5
Cordova:
cordova (Cordova CLI) : 8.0.0
Cordova Platforms : none
Cordova Plugins : no whitelisted plugins (0 plugins total)
System:
Android SDK Tools : 26.1.1
NodeJS : v8.11.3
npm : 5.6.0
OS : Windows 10