1

I have tried to open redirect external website when button click in Angular , but its not working , Please help

<button  [routerLink]="www.google.com" >
   Goto google
  </button>

2 Answers2

0

You can use anchor tag for the same, using target as _blank will cause this to open in a new tab. Remove it if you need to redirect to the same tab.

 <a href="www.google.com" target="_blank">Go to Google</a>

If you want to use button, try below:

<button onclick="window.location.href='https://google.com';" value="Go to Google" />
Ritesh Waghela
  • 3,474
  • 2
  • 19
  • 25
0
<a href="https://www.google.com/">Goto google</a>

This will redirect the user to Google website

[routerLink] is for internal URL (within your Angular App)

Abhilash Augustine
  • 4,128
  • 1
  • 24
  • 24