使用 Angular2 应用过滤器时如何构建可读的 url

How to build readable urls when filters are applied using Angular2

我有一个网站 (textnook),用户可以在其中按作者姓名、出版商等过滤书籍。在早些时候应用过滤器时,我使用 javascript 构建 url并呈现请求,它看起来像 /book/search/?author_id=1 我可以使用 angular 2 路由使 url 在传递参数时可读吗?是否可以像单页应用程序那样做?

当然,这就是 Angular 路由器的用途。具有可读的可收藏 URL 的单页应用程序。

您可以将参数编码为 "directory" 或查询参数。

Can I use angular 2 route to make the url readable while passing the parameters. Is it possible do it like a single page application?

是的。 ?author_id 可以配置为 查询参数 : https://angular.io/docs/ts/latest/guide/router.html

从 link 开始,它需要 ; 而不是 &/?