Jac*_*ckM 8 angular2-routing angular
使用Angular 2 beta.0
我有一个像这样的组件结构
App (Has RouteConfig)
-> List
| -> ListItem (Want to use RouterLink from here)
Run Code Online (Sandbox Code Playgroud)
这会导致错误: Component "List" has no route config.
所以我在这个List组件上放了一个RouteConfig ......
@RouteConfig([
{path: '/:id', name: 'Details', component: Detail}
])
Run Code Online (Sandbox Code Playgroud)
但我得到一个像角度的错误 Error: Child routes are not allowed for "/list". Use "..." on the parent's route path.
我尝试在该路由配置中的/ list路径之前和之后添加这3个点...但没有成功.
路由器上的文档很轻,虽然我知道这应该是基于ui-router,我没有看到并行添加嵌套路由
Aic*_*ink 19
您可以在父组件中使用它:
@RouteConfig([
{path: '/', component: HomeComponent, as: 'Home'},
{path: '/list/...', component: ListComponent, as: 'List'}
])
Run Code Online (Sandbox Code Playgroud)
然后在您的ListComponent定义您的子路线:
@RouteConfig([
{ path: '/:id', component: ListItem, as: 'ListItem' }
])
Run Code Online (Sandbox Code Playgroud)
确保ListComponent有一个<router-outlet></router-outlet>...
| 归档时间: |
|
| 查看次数: |
9371 次 |
| 最近记录: |