更改 angular 路由器 URL 方案
Change angular router URL scheme
当我尝试将一些参数传递给我的 URL 时,angular 路由器提供了一些我不太喜欢的 URL 方案。
this 示例中的 URLS 如下所示:
https://whatever.io/crisis-center;id=2;foo=foo
我希望它们看起来像一些 'conventional' URL。
类似于:https://whatever.io/crisis-center?id=2&foo=foo
有没有办法更改 Angular2^ 路由器的 URL 方案?如果是这样,关于如何做到这一点有什么建议或例子吗?
在 angular
中路由时可以使用 query parameters
this.router.navigate(['/crisis-center'], { queryParams: { id: 2, 'foo': 'foo' } });
您的 URL 将如下所示:
http://localhost:4200/crisis-center'?id=2&foo=foo
当我尝试将一些参数传递给我的 URL 时,angular 路由器提供了一些我不太喜欢的 URL 方案。
this 示例中的 URLS 如下所示:
https://whatever.io/crisis-center;id=2;foo=foo
我希望它们看起来像一些 'conventional' URL。
类似于:https://whatever.io/crisis-center?id=2&foo=foo
有没有办法更改 Angular2^ 路由器的 URL 方案?如果是这样,关于如何做到这一点有什么建议或例子吗?
在 angular
中路由时可以使用query parameters
this.router.navigate(['/crisis-center'], { queryParams: { id: 2, 'foo': 'foo' } });
您的 URL 将如下所示:
http://localhost:4200/crisis-center'?id=2&foo=foo