Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

routerLink和routerLinkActive动态传参 #46

Open
deepthan opened this issue Dec 24, 2018 · 0 comments
Open

routerLink和routerLinkActive动态传参 #46

deepthan opened this issue Dec 24, 2018 · 0 comments

Comments

@deepthan
Copy link
Owner

deepthan commented Dec 24, 2018

假设个场景:做一个菜单,有的节点是点击出现子节点,有的节点是点击跳转路由

想要实现是连接则跳转,不是连接则不跳转,可以这样做。

ts

isLink : boolean = false;

html

<div
    [routerLink]="isLink ?   data.url : null"
    routerLinkActive="node-active">
</div>

css

.node-active{
    background: #006189;
}

可以正常跳转,但是路由只要是Null的话就会处于激活状态,所以还需对routerLinkActive进行判断。

html

<div
    [routerLink]="isLink ?  null : data.url"
    routerLinkActive="{{isLink ? 'node-active' : null }}">
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant