Angular 2.0.0-rc3:与routerLinkActive进行部分路由匹配 [英] Angular 2.0.0-rc3: partial route matching with routerLinkActive

查看:207
本文介绍了Angular 2.0.0-rc3:与routerLinkActive进行部分路由匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在主要路由中使用了routerLinkActive.

I'm using routerLinkActive in my primary routing.

<a [routerLink]="/user" routerLinkActive="active">Bob</a>

当URL为/user时,会将active类添加到a标记中,但是在主要路由下,我还有一些辅助路由,因此 当URL为/user/aa时,活动目录将被删除.

When the URL is /user, the active class will be added to the a tag, but under the primary route, I also have a few secondary routes, so when the URL is /user/aa, the active will be removed.

我希望当URL是/user/aa/user/bb时,主要路由的类active仍然存在.

I hope that when the URL is either /user/aa or /user/bb, the primary route's class active still exists.

我该怎么办?

推荐答案

添加

[routerLinkActiveOptions]="{ exact: false }"

据我所知,这将是下一次更新的默认设置.

As far as I know this is going to be the default with the next update.

这篇关于Angular 2.0.0-rc3:与routerLinkActive进行部分路由匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆