简体   繁体   English

使用@Routes的Angular 2嵌套路由

[英]Angular 2 Nested Routes using @Routes

I'm trying to do something seemingly simple. 我正在尝试做一些看似简单的事情。 I have the following defined: 我有以下定义:

@Routes([
    { path: '/stores', component: StoresComponent },
    { path: '/stores/new', component: StoresCreateComponent}
])

When I navigate to /stores I display a list of existing stores. 当我导航到/stores显示现有商店的列表。 I have a link on that page to navigate to a screen to create a new store. 我在该页面上有一个链接,以浏览到创建新商店的屏幕。 However, when I navigate to /stores/new , I get the following: 但是,当我导航到/stores/new ,会得到以下信息:

browser_adapter.ts:78Error: Uncaught (in promise): Component 'StoresComponent' does not have route configuration

I'm pretty new to Angular so I'm not entirely sure what I need to do in order to get a route like that working. 我对Angular来说还很陌生,所以我不确定要实现这样的路线我需要做什么。

Order routes so that more specific ones come first and less specific ones last. 对路线进行排序,以便更具体的路线排在最前面,而最不具体的路线排在最后。 That's a current limitation of the RC.1 router. 这是RC.1路由器的当前限制。

@Routes([
    { path: '/stores/new', component: StoresCreateComponent}
    { path: '/stores', component: StoresComponent },
])

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

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