Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trigger a new window to be opened from a button click in Angular 2

I have a button and on click of that button a new window should be opened with a new provided URL. For example:

<button class="btn btn-help"(click)="helpWindow($event)" type="submit"></button> 

How do I handle this even at backend in the typescript file? I will get the URL from REST API and I want to open a new window with that link

like image 740
Protagonist Avatar asked Jan 02 '17 09:01

Protagonist


People also ask

Which of the following is the correct way to bind a click event to the button?

Events are handled in Angular using the following special syntax. Bind the target event name within parentheses on the left of an equal sign, and event handler method or statement on the right. Above, (click) binds the button click event and onShow() statement calls the onShow() method of a component.


1 Answers

helpWindow(event) {
  window.open(document.URL, '_blank', 'location=yes,height=570,width=520,scrollbars=yes,status=yes');
}

See also https://stackoverflow.com/a/14132265/217408

like image 84
Günter Zöchbauer Avatar answered Nov 15 '22 07:11

Günter Zöchbauer