简体   繁体   中英

Ionic 5(Angular9)-Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'profile'

I am encounter this erro when trying to click on Home -> toggle menu and navigate to "Profile".I've try multiple approcah yet still same erro.please help me

在此处输入图像描述

App-routig.module.ts

 import { NgModule } from '@angular/core'; import { PreloadAllModules, RouterModule, Routes } from '@angular/router'; const routes: Routes = [ { path: 'home', loadChildren: () => import('./home/home.module').then( m => m.HomePageModule) }, { path: 'profile/', loadChildren: () => import('./profile/profile.module').then( m => m.ProfilePageModule) }, ]; @NgModule({ imports: [ RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules }) ], exports: [RouterModule] }) export class AppRoutingModule { }

app.component.ts

 app.component.ts export class AppComponent { navigate: any; //new added for toggle menu this.sideMenu(); //new added for toggle menu this.initializeApp(); } } sideMenu() { //new added for toggle menu this.navigate = [ { title: 'Home', url: './home', icon: 'home-outline', //icons: 'home-outline', }, { title: 'Profile', url: './profile', icon: 'person-circle-outline', }, ];

app.module.ts

在此处输入图像描述

Your route path is wrong. Maybe just a typo. Remove the extra forward slash / for profile path.

{
    path: 'profile',
    loadChildren: () => import('./profile/profile.module').then( m => m.ProfilePageModule)
},

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM