Skip to content

Instantly share code, notes, and snippets.

@maximLyakhov
Created April 24, 2023 12:27
Show Gist options
  • Save maximLyakhov/759923401c85428bd713c3ab2c1ac9bf to your computer and use it in GitHub Desktop.
Save maximLyakhov/759923401c85428bd713c3ab2c1ac9bf to your computer and use it in GitHub Desktop.
Angular Router: Open In new Tab
class Component {
public navigate({row: {id}, type}: RowAction<Item>): void {
if (type.includes('ctrl')) {
const url = this.router.serializeUrl(this.router.createUrlTree([id]));
window.open(url, '_blank'); // new tab
return;
}
this.zone.run(() => this.router.navigate([id])).then();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment