如何将RouterLinkActive与空的routerLink一起使用 [英] How to use routerLinkActive with empty routerLink

查看:70
本文介绍了如何将RouterLinkActive与空的routerLink一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下标签栏链接,第一个应该为空:

I have the following tab bar links and the first one is supposed to be empty:

<nav md-tab-nav-bar>
          <a md-tab-link [routerLink]="'./'" 
             routerLinkActive #rla="routerLinkActive" [active]="rla.isActive">
            My tab
          </a>
...
</nav>

链接工作正常,但未触发活动状态.

The link works fine but the active state is not triggered.

处理要激活的选项卡的空routerlink的正确方法是什么?

What is the proper way to handle empty routerlink for the tab to be activated?

推荐答案

尝试使用此方法

<a [routerLink]=" ['./'] "
    routerLinkActive="active" [routerLinkActiveOptions]= "{exact: true}">
    My tab
</a>

https://angular.io/docs/ts/latest/api/router/index/RouterLinkActive-directive.html

这篇关于如何将RouterLinkActive与空的routerLink一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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