Open new tab when click on a div Angular

Viewed 8702

I am developping an angular project my problem is that i want when i click into a div i open a new tab but it doesn't work for me. It worked for <a>. Can someone help me ? this is my code:

<div class="application"   target="_blank" routerLink="/home">
    <img class="imgChart " src="./../assets/img/charts.jpg" alt="image 1">
    <div class="title-app">{{'STORE.APPSTAT' | translate}}</div>
    <p>{{'STORE.DESCRIPTIONSTATISTIQUE' | translate}}</p>
</div>
1 Answers

You can open a window by calling the open method on the Window object and passing in a URL.

Componenet.html:

<div class="application" (click)='openNewTab()'>
    <img class="imgChart " src="./../assets/img/charts.jpg" alt="image 1">
    <div class="title-app">{{'STORE.APPSTAT' | translate}}</div>
    <p>{{'STORE.DESCRIPTIONSTATISTIQUE' | translate}}</p>
</div>

Component.ts:

  public openNewTab() {
    window.open('http://www.google.com', '_blank');
  }
Related