angular - 无法匹配任何路线。 URL段: '' : When trying to use child routes and Ng2

标签 angular angular2-routing

我有the following plunker ,这是行不通的。为了让它工作,我可以注释掉......

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

如果我不这样做,我就会......

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

如何添加子路线?

最佳答案

您应该提供不同的路径名,直到使用pathMatch: 'full'Forked .

有关该主题的更多信息,请参阅 Angular Router: Empty Paths, Componentless Routes, and Redirects .

关于angular - 无法匹配任何路线。 URL段: '' : When trying to use child routes and Ng2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40566685/

相关文章:

HTTP 错误处理程序中的 Angular 2 router.navigate()

javascript - 路由器 : Redirect from within a promise returned by a `canActivate` method

node.js - 无法通过express/heroku查看Angular应用程序?

javascript - Angular2 等待 DOM 元素加载

angular - 在 IE11 中单击 angular2 时选择输入文本字段中的文本

angular - 路由器链接不适用于共享模块内的组件

angular - 在 router-outlet 注入(inject)的延迟加载模块中使用面包屑组件

javascript - 如何使用angular 2在URl中使用问号

javascript - FileReader onload 不在 Controller 范围内 Angular 2

javascript - 将子组件的输出发送到父组件 - Angular 2