Home > Enterprise >  How to redirect to external link in Angular?
How to redirect to external link in Angular?

Time:11-11

I need to set external link to my Facebook account

<a target="_blank" href="{{socialFacebook.url}}">
      <mat-icon class='icons-svg' svgIcon="facebook-icon" ></mat-icon>
</a>

url: facebook.com/Myuseraccount But when I try navigate to this url it redirect me to this : http://localhost:4200/facebook.com/nikita.iliciov.5 with localhost:4200 in front of my url

I try to set my code like this <a target="_blank" href="https://{{socialMedia.url}}"> with https in front of url but when I put my Url it looks like https://https//www.facebook.com/Myuseraccount, with double of https

How I can fix it ?

CodePudding user response:

Try using property binding :

<a target="_blank" [href]="socialFacebook.url">
      <mat-icon class='icons-svg' svgIcon="facebook-icon" ></mat-icon>
</a>

and make sure your url starts with https or http

socialFacebook.url = https//www.facebook.com/Myuseraccount

CodePudding user response:

Seems like you missed the : after the protocol of your socialFacebook.url attribute. Then the URL is appended to the actual URL.

If you add a protocol correctly it well be seen as a own single URL.

  • Related