推送通知的Angular 2组件 - ng2-notifications

ng2-notifications 是一个强大的Angular 2+ 开源组件,它利用了Web的Notifications API,允许你的应用在用户切换标签或专注于其他应用程序时,也能显示系统级别的推送通知。这款组件设计简洁,兼容现有的各种操作系统和浏览器的通知系统。
在线演示与快速启动
想立即体验?点击这里查看在线演示。
要在自己的项目中快速启用ng2-notifications,只需执行以下步骤:
$ npm install ng2-notifications --save
接着,在你的App模块中引入并使用该组件:
import { PushNotificationComponent } from 'ng2-notifications/ng2-notifications';
@Component({
selector: 'my-app',
template: `
<push-notification
title="ng2-notifications"
body="Component for Native Push Notifications"
icon="https://goo.gl/3eqeiE">
</push-notification>
`,
directives: [PushNotificationComponent]
})
使用方法
基础的推送通知可以通过设置标题、内容和图标属性来创建,如下所示:
<push-notification
title="ng2-notifications"
body="Component for Native Push Notifications"
icon="https://goo.gl/3eqeiE">
</push-notification>
若要实现数据绑定,可以这样做:
<push-notification
[title]="notification.title"
[body]="notification.description"
[icon]="notification.icon">
</push-notification>
自动关闭
通过设置closeDelay属性,你可以让通知在指定时间后自动关闭。例如,下面的例子将在5秒后自动关闭:
<push-notification
...
closeDelay="5000">
</push-notification>
控制何时触发通知
通过添加模板变量并在事件上调用.show() 方法,你可以控制何时展示通知:
<push-notification #notification
...
(load)="notification.show()">
</push-notification>
点击事件处理
给通知添加点击事件处理器,只需要使用(action)事件:
<push-notification
...
(action)="myFunction($event)">
</push-notification>
显示和关闭事件
监听通知的显示和关闭事件,可以为它们添加回调函数:
<push-notification
...
(show)="myShowFunction($event)"
(close)="myCloseFunction($event)">
</push-notification>
错误事件
当遇到错误时,可通过(error)事件进行处理:
<push-notification
...
(error)="handleError($event)">
</push-notification>
其他选项
此外,还有更多自定义选项可供选择,比如data、tag、dir(默认值:'auto')以及lang(默认值:'en-US')。
浏览器支持
查看完整的浏览器兼容性列表。请注意,有些特性仍处于建议阶段,或者目前尚未被所有浏览器支持,如renotify、silent、sound、vibrate、sticky 和 noscreen。另外,如果你在Chrome的隐私浏览模式下,将无法收到通知。
许可证
本项目采用MIT许可证,详情见LICENSE 文件。
版权 © 2017 Alex Castillo
许可在此明确授予,无需付费,任何个人或实体均可获得一份本软件及其相关文档的副本,不受限制地使用、复制、修改、合并、发布、分发、转授权和/或销售本软件的副本,以及允许为其接收软件的人员这样做,但须遵守以下条件:
上述版权声明和许可通知应包含在本软件的所有副本或实质部分中。
本软件提供“原样”状态,不附带任何形式的明示或暗示保证,包括但不限于对适销性、特定用途适用性和非侵权性的保证。在任何情况下,作者或版权持有者都不应对因使用、不能使用本软件所产生的直接、间接、偶然、特殊、惩罚性或后果性损害承担责任,即使已被告知可能出现此类损害。
PaddleOCR-VLPaddleOCR-VL 是一款顶尖且资源高效的文档解析专用模型。其核心组件为 PaddleOCR-VL-0.9B,这是一款精简却功能强大的视觉语言模型(VLM)。该模型融合了 NaViT 风格的动态分辨率视觉编码器与 ERNIE-4.5-0.3B 语言模型,可实现精准的元素识别。Python00- DDeepSeek-OCR暂无简介Python00
openPangu-Ultra-MoE-718B-V1.1昇腾原生的开源盘古 Ultra-MoE-718B-V1.1 语言模型Python00
HunyuanWorld-Mirror混元3D世界重建模型,支持多模态先验注入和多任务统一输出Python00
AI内容魔方AI内容专区,汇集全球AI开源项目,集结模块、可组合的内容,致力于分享、交流。03
Spark-Scilit-X1-13BFLYTEK Spark Scilit-X1-13B is based on the latest generation of iFLYTEK Foundation Model, and has been trained on multiple core tasks derived from scientific literature. As a large language model tailored for academic research scenarios, it has shown excellent performance in Paper Assisted Reading, Academic Translation, English Polishing, and Review Generation, aiming to provide efficient and accurate intelligent assistance for researchers, faculty members, and students.Python00
GOT-OCR-2.0-hf阶跃星辰StepFun推出的GOT-OCR-2.0-hf是一款强大的多语言OCR开源模型,支持从普通文档到复杂场景的文字识别。它能精准处理表格、图表、数学公式、几何图形甚至乐谱等特殊内容,输出结果可通过第三方工具渲染成多种格式。模型支持1024×1024高分辨率输入,具备多页批量处理、动态分块识别和交互式区域选择等创新功能,用户可通过坐标或颜色指定识别区域。基于Apache 2.0协议开源,提供Hugging Face演示和完整代码,适用于学术研究到工业应用的广泛场景,为OCR领域带来突破性解决方案。00- HHowToCook程序员在家做饭方法指南。Programmer's guide about how to cook at home (Chinese only).Dockerfile013
Spark-Chemistry-X1-13B科大讯飞星火化学-X1-13B (iFLYTEK Spark Chemistry-X1-13B) 是一款专为化学领域优化的大语言模型。它由星火-X1 (Spark-X1) 基础模型微调而来,在化学知识问答、分子性质预测、化学名称转换和科学推理方面展现出强大的能力,同时保持了强大的通用语言理解与生成能力。Python00- PpathwayPathway is an open framework for high-throughput and low-latency real-time data processing.Python00