简体   繁体   English

Angular 2内部如何进行辅助路由?

[英]How have secondary routing inside Angular 2?

I have routing setup for my application with a . 我的应用程序具有路由设置。 Everything is fine but one of my views loads a side bar which I want to use a different . 一切都很好,但是我的观点之一是加载了一个我要使用不同的边栏。 When I try to add additional routing to the component I get 'Child routes are not allowed for "xxx" use "..." on the parent's route path. 当我尝试向组件添加其他路由时,我得到“不允许将子路由用于“ xxx”,请在父级的路由路径上使用“ ...”。

Has anybody added multiple layers of routing that can help? 是否有人添加了多层路由可以提供帮助? thanks! 谢谢!

Parent routes use a special ... syntax 父路由使用特殊的...语法

//parent route
@RouteConfig([
    new Route({path: '/', component: DemoPage, name: 'Home'}), 
    new Route({path: '/demo/...', component: DemoPage, name: 'Demo'})
})

//child routes defined in separate route config
@RouteConfig([
    new Route({ path: '/spreadsheet', component: Spreadsheet, name: 'Spreadsheet' })
//etc   
])

I have a tutorial here: http://www.syntaxsuccess.com/viewarticle/routing-in-angular-2.0 我在这里有一个教程: http : //www.syntaxsuccess.com/viewarticle/routing-in-angular-2.0

You can also see nested routes in action here: 您还可以在此处查看嵌套路线的运行情况:

http://www.syntaxsuccess.com/angular-2-samples/#/demo/spreadsheet http://www.syntaxsuccess.com/angular-2-samples/#/demo/spreadsheet

The left nav is using child routes. 左导航正在使用子路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM