百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
A

angular2-notifications

> 前端框架
开源

一个轻量级且易于使用的通知库,适用于 Angular。

743 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

一个轻量级且易于使用的通知库,适用于 Angular。

Angular2-Notifications

这是一个轻量级且易于使用的通知库,适用于 Angular 2。它支持常规页面通知(弹出消息)和推送通知。 推送通知已移至单独的库 ng-push

目录

  • 示例
  • 设置
  • SystemJS
  • Webpack
  • 设置
  • 创建通知
  • 使用 TemplateRef 的示例
  • 订阅点击
  • 选项

示例

请在此处查看实时演示: 实时演示

设置

安装库

bash
npm install --save angular2-notifications
# Or using Yarn for a faster installation
yarn add angular2-notifications

SystemJS

如果您使用 SystemJs,请在 system.config.js 中映射库。

javascript
var map = {
    'angular2-notifications': 'node_modules/angular2-notifications'
}

var packages = {
    'angular2-notifications': { main: './dist/index.js', defaultExtension: 'js' }
}

Webpack

如果您使用的是 Webpack >= 2,只需将库包含在 main.ts 或 vendor.ts 文件中即可

typescript
import 'angular2-notifications';

设置

将 SimpleNotificationsModule 导入到您的根 AppModule 中(如果尝试将其导入到共享模块中,则不会起作用)

typescript
import { SimpleNotificationsModule } from 'angular2-notifications';

@NgModule({
    imports: [
        BrowserModule,
        // Animations need to be imported in to your project to use the library
        BrowserAnimationsModule, 
        SimpleNotificationsModule.forRoot()
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
export class AppModule { }

将 SimpleNotificationsComponent 添加到您要使用通知的组件中,或者添加到您的顶级组件中,以便在子组件中使用。

javascript
...
template: ''
...

您还需要在组件中使用 NotificationsService 来创建或删除通知。

javascript
...
constructor( private _service: NotificationsS

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptangular2notificationstoasts

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架