0

I have a search.component.ts, where I am fetching data according to search criteria. Now I want to generate a report which is a basic html page and not search.component.html, based on the data I have in my search component. I want the html page to be opened on a different tab. Is there any suitable solution?

Anurag
  • 482
  • 6
  • 23

1 Answers1

0

Create a button in your template:

<button type="button" (click)="redirect">Redirect</button>

Create a function in your component:

redirect(){
    window.open(
        'https://support.wwf.org.uk/earth_hour/index.php?type=individual',
        '_blank' // <- This is what makes it open in a new window.
    );
}

Ps. A simple google search found the window.open() function that accepts a second param to open a new window. see link JavaScript: location.href to open in new window/tab?

Community
  • 1
  • 1
Rossco
  • 3,563
  • 3
  • 24
  • 37