Angular 5 snackbar 通知

标签 angular notifications angular-material toast

我想实现像这样的通知消息

"Success! Your Details Added"
"Warning! Something Went Wrong"
"Danger! You don't have access to this"

我已经在我的应用程序中使用 Angular Material 我可以使用 'snack-bar'用于通知目的?

我还发现了一些相关的toaster at npm

如果有另一种方法可以做到这一点,请给我建议。

最佳答案

我用这个ngx-toastr , demo

  • 不通过 ViewContainerRef 的 Toast 组件注入(inject)
  • 没有使用 *ngFor。更少的脏检查和更高的性能。
  • AoT 编译和延迟加载兼容
  • 自定义 toasts 的组件继承
  • SystemJS/UMD 汇总包
  • 使用 Angular 的 Web Animations API 的动画(需要 polyfill 旧设备)
  • 将 toasts 输出到可选的目标指令

关于Angular 5 snackbar 通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48675908/

相关文章:

unit-testing - 从父组件传递到子组件的 Angular 2 单元测试数据

c# - SQL Server 通知 - 我的 OnChange 不触发

css - 如何使用material design让div float 在页面右侧(贴)

javascript - 如何访问 angularjs promise 中的数据?

angular - 如何覆盖 Material 中的 matTreeNodePadding 样式?

javascript - Rxjs 在限制后递增循环计数器

angular - 类型 'first' 上不存在属性 'Observable<string>'

angular - Angular 6 更新后,ng build --prod 产生 "Error: Expected to find an ngsw-config.json configuration file"

python - 将 Python 最小化到系统托盘并生成通知?

javascript - 如何使用 laravel 每 x 秒自动刷新一个 div