一个轻量级且易于使用的通知库,适用于 Angular。
这是一个轻量级且易于使用的通知库,适用于 Angular 2。
它支持常规页面通知(弹出消息)和推送通知。推送通知已移至单独的库 ng-push
请在此处查看实时演示: 实时演示
安装库
npm install --save angular2-notifications
# Or using Yarn for a faster installation
yarn add angular2-notifications如果您使用 SystemJs,请在 system.config.js 中映射库。
var map = {
'angular2-notifications': 'node_modules/angular2-notifications'
}
var packages = {
'angular2-notifications': { main: './dist/index.js', defaultExtension: 'js' }
}如果您使用的是 Webpack >= 2,只需将库包含在 main.ts 或 vendor.ts 文件中即可
import 'angular2-notifications';将 SimpleNotificationsModule 导入到您的根 AppModule 中(如果尝试将其导入到共享模块中,则不会起作用)
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 添加到您要使用通知的组件中,或者添加到您的顶级组件中,以便在子组件中使用。
...
template: ''
...您还需要在组件中使用 NotificationsService 来创建或删除通知。
...
constructor( private _service: NotificationsS暂无开放 Issues,或尚未同步最近议题。