我希望有与该URL角2路由器:多个路由参数
/collections/:collectionId/books/:bookId/:title
例如路由
/collections/10/books/456678/my-book.html
在我的应用程序,文件routing.module.ts
{path: 'collections/:collectionId/books/:bookId/:title', component: BookDetailsComponent},
是可以在不使用嵌套路由器网点?
我试图
this.router.navigate(['/collections',{collectionId: 10, bookId: 456678, title: "my-book.html"}]);
却得到了这样的错误
Cannot match any routes. URL Segment: 'collections;collectionId=10;bookId=456678;title=my-book.html'
如果我通过了PARAMATERS作为一个数组,那么
this.router.navigate(['/collections', 10, 456678, "my-book.html"]);
我得到
Error: Cannot match any routes. URL Segment: 'collections/10/456678/my-book.html
我设法实现我想要的东西使用“集合”路线下一个“图书”孩子的路线,但我想这样做没有嵌套的路线。
感谢
正是你传递什么作为数组'router.navigate'? – Dimanoid
@Dimanoid:我编辑我的问题表现出更多的代码 – David
你错过了“书”为路径 – Dimanoid