Post

Angular2で「Use "..." on the parent's route path.」が起こる場合の対処法

Angular2 の ComponentRouter を使った場合に発生するUse "..." on the parent's route path.エラーの対処法です。
完全に小ネタ。

Nest した Routing の場合、親の@RouteConfigの path に...を付ける必要がある。

1
2
3
4
5
6
7
8
9
10
// parent
@RouteConfig([
  {path: '/', component: HomeComponent, as: 'Home'},
  {path: '/list/...', component: ListComponent, as: 'List'}
])

// child
@RouteConfig([
  { path: '/:id', component: ListItem, as: 'ListItem' }
])

参考)

angular2 - Use RouterLink from a nested component - Stack Overflow
https://stackoverflow.com/questions/34363176/use-routerlink-from-a-nested-component

This post is licensed under CC BY 4.0 by the author.