【发布时间】:2019-11-21 06:32:32
【问题描述】:
我有一个项目仪表板,其中有 2 个子应用程序。
├───projects
│ ├───app1
│ │ ├───e2e
│ │ │ └───src
│ │ └───src
│ │ ├───app
│ │ │ ├───form
│ │ │ ├───home
│ │ │ └───page-not-found
│ │ ├───assets
│ │ └───environments
│ ├───app2
│ │ ├───e2e
│ │ │ └───src
│ │ └───src
│ │ ├───app
│ │ │ ├───core
│ │ │ ├───home
│ │ │ ├───mail-view
│ │ │ ├───mailbox
│ │ │ ├───models
│ │ │ ├───page-not-found
│ │ │ └───service
│ │ ├───assets
│ │ └───environments
│ └───app3
│ ├───e2e
│ │ └───src
│ └───src
│ ├───app
│ ├───assets
│ └───environments
├───resources
└───src
├───app
│ ├───components
│ │ ├───navigation
│ │ └───progressbar
│ ├───core
│ │ ├───authentication
│ │ └───service
│ ├───dashboard
│ │ ├───models
│ │ ├───service
│ │ └───widget
│ ├───login
│ └───shared
│ ├───common
│ │ ├───config
│ │ └───service
│ └───core
├───assets
└───environments
从仪表板应用导航到 app1 和 app2 的工作正常。
app2 mail-view中,mailbox是home组件的子组件。
const routes: Routes = [
{ path: 'mail', redirectTo: 'mail/home', pathMatch: 'full' },
{ path: 'mail/home', pathMatch: 'full', component: HomeComponent,
children: [
{ path: '', pathMatch: 'full', component: LoaderComponent },
{ path: 'mailbox/:type', component: MailboxComponent , resolve: { response: MailboxResolverService }},
{ path: 'mailbox/BLK/list/:header', pathMatch: 'full', component: BulkMailListComponent },
{ path: 'viewMail/:type/:mailId', pathMatch: 'full', component: MailViewComponent }
]
/*canActivate: [AuthGuard]*/ },
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
当我尝试导航到任何子组件时,我收到错误“找不到路径”。
this.route.navigate(['./mailbox/', AppConstants.MAILBOX_TYPE.INBOX_I], {relativeTo: this.aRoute});
custom-error-handler.service.ts:25 Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'mail/home/mailbox/INBI'
Error: Cannot match any routes. URL Segment: 'mail/home/mailbox/INBI'
at ApplyRedirects.push../node_modules/@angular/router/fesm5/router.js.ApplyRedirects.noMatchError (router.js:2459)
at CatchSubscriber.selector (router.js:2440)
- 在使用子模块时是否有特殊的方式来声明子模块
- 或者是以不同的方式完成导航。
提前致谢。
【问题讨论】:
-
什么是
./mailbox/路由中不需要.。给出完整路线/mail/home/mailbox -
当您使用
this.route.navigate(['/mailbox/']时,您的网址应该是/mail/home/ -
@Joel 我曾尝试使用“邮箱”,结果 URL 与“邮件/家庭/邮箱/INBI”相同。
标签: angular typescript routes