我使用了angular-cli工具来创建路线。它使文件夹前面带有+,即
+dashboard
+document
我不知道如何使用angular-cli工具制作子路线。确实没关系,但是我更愿意在我的应用程序结构中采用约定的约定来描述子路由。
那我该怎么办?
我会在这样的父路径下放置一个文件夹吗
app\+document\+chapter
做这样的事更好吗
app\+document
app\+chapter
除此之外,我对总体路线还是有些困惑。我的理解是,有一条不赞成使用的路线和一条新路线。我想我正在使用新系统,因为它是由angular-cli工具生成的。无论如何,我要嵌套多个级别的子路由。我想知道这看起来是否合法。
@Routes([
{ path: '/', component: DashboardComponent },
{ path: '/document/:id', component: ReaderComponent,
children: [
{ path: '', redirectTo: 'chapter/0', pathMatch: 'full' },
{ path: 'chapter/:id', component: ChapterComponent,
children: [
{ path: '', redirectTo: 'para/0', pathMatch: 'full' },
{ path: 'para/:id', component: ParagraphComponent }
]}
]
}
])
所以http://my-url/document/1
应该带我http://my-url/document/1/chapter/0/para/0
去做,这是最好的方法吗?我喜欢它,因为它允许进行深度链接等。它也似乎redirectTo不起作用。
但是我对这一切还是有点陌生,我想让我的应用程序设计尽可能保持“常规”
似乎您混合了来自不同不兼容路由器版本的内容。@Routes()
来自较旧的路由器版本,但您的路由配置适用于最新的路由器版本。
有关如何配置新路由器的信息,请参见https://angular.io/docs/ts/latest/guide/router.html#!#route-config。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句