在 typescript 中,可以这样定义子路由:
export const routes: Routes = [
{ path: '', redirectTo: 'product-list', pathMatch: 'full' },
{ path: 'product-list', component: ProductList },
{ path: 'product-details/:id', component: ProductDetails,
children: [
{ path: '', component: Overview },
{ path: 'specs', component: Specs }
]
}
];
在dart中,@ RouteConfig元数据类似,但是Route上没有childen属性来定义子路由。
在Dart中定义子路线的正确方法是什么? dart的Angular 2.0已发布,但在使用dart中的路线时仍然完全缺少文档。
最佳答案
是的,缺少文档,对不起。我们有一个新的小组来解决这个问题,它肯定会变得更好。暂时,我可以帮上忙-您的ProductDetails
组件只需要声明它自己的@RouteConfig
:
@Component(...)
@RouteConfig(const [
const Route(path: '', component: Overview),
....
])
class ProductDetails {}
关于angular - 如何在Angular 2.0中为Dart定义子路线,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40273405/