1

I am making a About section page, in which there are icons clicking which we can go to their social handles like, facebook, twitter, linkedin, etc.

my code:

<a [href]="'www.facebook.com/user'" target="_blank"><i class="zmdi  zmdi-facebook-box"></i></a>

but this creates link http://localhost:4200/ prefixed to www.facebook.com/user, searching on the internet, i got to two methods

1.some posts says to use router or resolver, canActivate guards and other angular techniques. Medium post StackOverFlow

  1. and another method is just to add http to the link. i.e.
<a [href]="'http://www.facebook.com/user'" target="_blank"><i class="zmdi  zmdi-facebook-box"></i></a>

the second method worked for me, but i am left confused, that whether it's the proper way to route to external link in angular app.

Please help me understand which is the correct way to route to external links, and if second method is enough, in what cases do we use the first method.

shubh kr
  • 21
  • 6

0 Answers0