Pass NavigationExtras to routerLink in template

不羁的心 提交于 2019-12-05 01:23:15

There is no way (for now and afaik) to both have routerLinkActive and skipLocationChange simultaneously and expect the result you want. You can, according to the api, add options, but there is no skipLocationChange option.

You can however use the NavigationExtras from the router in combination with ActivatedRoute and base upon that whether or not the link should be active

update

Since 2.3.0-beta.0 you can add the skipLocationChange option to the routerLink directive:

<li><a [routerLink]="['route1']" skipLocationChange>Route1</a></li>

you can provide any of the NavigationExtras properties on the routerLink tag itself as individual attributes.

<a [routerLink]="['/user/bob']" [queryParams]="{debug: true}" fragment="education">
  link to user component
</a>

the documentation on RouterLink attributes is clear.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!