Search code examples
angularurlhref

base href in angular 4


I have a url like this: google.com (which is dynamically coming from backend api) When I click on the url it is taking me to localhost:4200/google.com instead of taking me to www.google.com

In my index.html I have this <base href="/"> Can anyone please help me in this? Thanks!


Solution

  • You need the complete url for correct redirection.

    If you dont have http/https in your URL , put // before the URL like below and pls check

    <a href="//google.com" >Click</a>