【问题标题】:How do I wipe a persisting query string [duplicate]如何擦除持久的查询字符串 [重复]
【发布时间】:2016-07-15 16:11:00
【问题描述】:

我有一个显示分页列表的组件,它是查询字符串中标识的当前页面,例如.../Listing?page=3

此列表的第一个元素是带有routeLink 的锚点,指向显示该行信息的组件:

<a [routerLink]="['Item', item.id]" routerLinkActive="active">{{ item.id }}</a>

当我点击链接时,URL 会更新为 .../Listing/Item/11?page=3

有没有办法在锚中指定查询字符串应该被擦除?

【问题讨论】:

标签: javascript angular angular2-routing


【解决方案1】:

通过更改锚点以包含一个空对象作为查询字符串参数使页面消失。

<a [routerLink]="['Item', item.id]" routerLinkActive="active" [queryParams]="{}">{{ item.id }}</a>

生成网址.../.../Listing/Item/11

【讨论】:

    猜你喜欢
    • 2020-12-24
    • 1970-01-01
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-22
    相关资源
    最近更新 更多