I'm trying to open a routerlink on a new tab instead of on the current page but regular html attributes like target _blank are not working.
<span routerLink="/custompage/{{city.id}}" class="badge badge-primary badge-pill">open</span>
I'm trying to open a routerlink on a new tab instead of on the current page but regular html attributes like target _blank are not working.
<span routerLink="/custompage/{{city.id}}" class="badge badge-primary badge-pill">open</span>
I don't think routerLink works with new tabs/windows.
You will have better luck with this, on your component.ts,
window.open(url, '_blank');
or this on your component.html
<a href="www.domain.com/custompage/{{city.id}}" target="_blank">
However, if you must use routerLink, there are other ways, such as writing your own custom directives. Check it out over here, that person has already written a sample implementation of it.
you can add target="_blank" to your link
it works for me:
<a routerLink="/News" routerLinkActive="active" target="_blank" rel="bookmark"></a>
I encountered the exact same issue and i think i've found the best of both worlds.
Change your DIV, SPAN into A tags. Add the href link but keep the routerLink.
<a routerLink="/custompage/{{city.id}}" href="/custompage/{{city.id}}" class="badge badge-primary badge-pill">open</a>
How it should work now :