view raw
user3737396 user3737396 - 6 months ago 32
AngularJS Question

using default browser behaviour for href and target in an <a> tag in angular2

In angular2, how do you implement the behavior of a simple

<a href="some url" target="_whatever">

without the routing module highjacking the url with the base href?

For example, expected behaviour for the following snippet in an angular template would be to open google in a new tab.

<a href="" target="_blank">

What actually happens is angular compiles the template as follows.

<a _ngcontent-kju-6="" target="_blank" ng-reflect-href="" href="">

Clicking on this opens [the base url]/ a new tab rather than simply


Prefixing your url with a protocol should give you what you want, e.g. ''.