Cannot match any routes. URL Segment: '':

2019-05-28 22:51发布

I have the following plunker, which does not work. In order to get it to work I can comment out...

RouterModule.forRoot([
      {
          path: "",
          component: TestComponent,
          children: [
              // {
              //    path:"",
              //    outlet: "other",
              //    component: TestComponent
              // }
          ]
      }
])

If I don't do that I get...

EXCEPTION: Uncaught (in promise): Error: Cannot match any routes. URL Segment: ''
Error: Cannot match any routes. URL Segment: ''

How do I add a child route?

2条回答
Deceive 欺骗
2楼-- · 2019-05-28 23:37

The router will stop after the first path is matched, which it does in the parent route. I've found it best to use a separate routing module for each router outlet. That being said, you get an ugly (other:route) for the auxilary route in your url. Admittedly, I have found some limitations to using auxiliary routes.

查看更多
一纸荒年 Trace。
3楼-- · 2019-05-28 23:40

You should give different path names until you use pathMatch: 'full'. Forked.

More about the subject in Angular Router: Empty Paths, Componentless Routes, and Redirects.

查看更多
登录 后发表回答