How to navigate to 2 url's on a button click in Angular

Viewed 52

When user clicks the button they should be navigated to www.example.com/logout and then automatically redirected to an iframe (www.example.com/home)

        setTimeout(window.location.href = "https://example.com/logout", 2000);
        this.iframeUrl = "https://example.com/home";
1 Answers
<button (click)="OnClick()"></button>
public OnClick(){
 this.http.post('www.example.com/logout').subscribe(data =>{
    //on success redirect to home
    },err => {
    //on error keep it in same page
    })
}

this is how we have to do the call on click of button

hopefully this helps you

Related