admin管理员组

文章数量:1390974

In our application, on a button click within a table, I need to open a new tab containing details of a record in the table. Using the below code I am navigating to a new URL. On the new page, resolvers are used to fetch details from back-end. Now the problem is I want to open this in a new tab.

 this.router.navigate(['/url/test'], {
      queryParams: {ip},
    }); 

I tried the below code. But it doesn't seems to work. It is redirecting to the default URL:

    this.router.navigate([]).then((result) => {
      window.open('/url/test?aa=' + aa, '_blank');
    });

Any help would be appreciated.

In our application, on a button click within a table, I need to open a new tab containing details of a record in the table. Using the below code I am navigating to a new URL. On the new page, resolvers are used to fetch details from back-end. Now the problem is I want to open this in a new tab.

 this.router.navigate(['/url/test'], {
      queryParams: {ip},
    }); 

I tried the below code. But it doesn't seems to work. It is redirecting to the default URL:

    this.router.navigate([]).then((result) => {
      window.open('/url/test?aa=' + aa, '_blank');
    });

Any help would be appreciated.

Share Improve this question edited Sep 4, 2020 at 16:00 Kate Orlova 3,2835 gold badges14 silver badges36 bronze badges asked Sep 4, 2020 at 10:37 user2900572user2900572 6213 gold badges9 silver badges24 bronze badges 1
  • 1 You don't the router to open a window. Remove the call to router.navigate and just call window.open. – The Head Rush Commented Sep 4, 2020 at 10:41
Add a ment  | 

1 Answer 1

Reset to default 4

I was using useHash as true for my urls, so when i navigated with hash in url it started working.

    this.router.navigate([]).then((result) => {
      window.open('/#/url/test?aa=' + aa, '_blank');
    });

本文标签: javascriptAngular 9 how to open URL in a new tab using routenavigate() with query stringStack Overflow