我正在尝试处理我的Angular应用程序中的情况,其中我通过routerLink加载了一些内部链接(一个部分中的链接 - 使用与应用程序其余部分不同的导航机制) . 这本身就足够好了,看起来像这样:

<a [routerLink]="'/section-start'" routerLinkActive="selected">Section Start</a>

但是,由于我首先设置了这些链接,我们现在有一些过滤器选择,我们也保存在URL中 . 所以我想弄清楚如何将这些传递到这里 . 我'm thinking Angular' s route.snapshot 可以在这里工作 . 所以我想这个:

<a [routerLink]="['/section-start', getParams()]" routerLinkActive="selected">Section Start</a>

并且 getParams() 看起来像这样:

getParams() {
    return this.route.snapshot;
}

这让我更接近......然而,我仍然最终加倍了主网址链接(这并不奇怪,因为它正在拍摄整个网址链接的快照),并说,如果我启用了“西班牙语”语言过滤器,地址栏中的网址最终看起来像这样:

http://somesite.com/section-start;url=section-start%3Bpn_lang_e%3Dtrue%3Bpn_lang_s%3DSpanish;

使用我常用的网站其他区域的路由机制,相同的参数会产生这样的网址(这应该是它应该是什么样的):

http://somesite.com/section-start;pn_lang_e=true;pn_lang_s=Spanish

由于我通过传入 getParams() 来接近正确的URL,我认为's a way I can clean this up/parse it differently to end up with the correct url string. Any ideas as to how I can do this - or is there a better approach that'与此不同?