Angular 2 Routing导航在新选项卡中运行(使用Angular Router naviagte)

Cod*_*Man 5 angular-routing angular angular-router

如果使用router.navigate,如何打开新的浏览器选项卡。

this.router.navigate([]).then(result => { window.location.href = link; });
Run Code Online (Sandbox Code Playgroud)

Man*_*her 21

试试这个。

this.router.navigate([]).then(result => {  window.open(link, '_blank'); });
Run Code Online (Sandbox Code Playgroud)

  • 为什么不直接 `window.open(link, '_blank');` 呢? (7认同)

mka*_*mid 6

目前我相信 angular 没有提供任何方法或服务来做到这一点,所以我必须使用window对象在新选项卡中打开链接 window.open(link, '_blank')