Insert a link into MatSnackBar

前端 未结 2 1998
太阳男子
太阳男子 2021-01-06 04:03

Is it possible to insert a link into the Angular Material 2 MatSnackBarModule?

I\'ve tried doing it inside the text, but it displays the html as text.

2条回答
  •  醉话见心
    2021-01-06 04:19

    If all you want to do is navigate the user when they click on the snackbar action, then there is a much more straightforward solution to this which does not involve creating a dedicated component.

    this.snackBar.open('Record has been created', 'View Record', { duration: 5000})
      .onAction()
      .subscribe(() => this.router.navigateByUrl('/app/user/detail'));
    

提交回复
热议问题