angulart 使用推送通知服务 NotificationsService

一、父组件
1.在父组件module文件导入

import { NgModule } from '@angular/core';
import {SimpleNotificationsModule} from 'angular2-notifications';

@NgModule({
  imports: [
    SimpleNotificationsModule.forRoot(),
  ],
})
export class AppModule { }

2.html 使用组件

<simple-notifications [options]="config" class="simple-notifications simple-notification-wrapper"></simple-notifications>

二、子组件
1.导入 ts文件

import { NotificationsService } from 'angular2-notifications';

2.注入服务

  constructor(private  notify: NotificationsService) {
  }

3.使用

  noDev() {
    this.notify.info('待开发');
  }

4.NotificationsService全部方法

export declare class NotificationsService {
    globalOptions: any;
    constructor(globalOptions: any);
    emitter: Subject<NotificationEvent>;
    icons: Icons;
    set(notification: Notification, to: boolean): Notification;
    success(title?: any, content?: any, override?: any): Notification;
    error(title?: any, content?: any, override?: any): Notification;
    alert(title?: any, content?: any, override?: any): Notification;
    info(title?: any, content?: any, override?: any): Notification;
    warn(title?: any, content?: any, override?: any): Notification;
    bare(title?: any, content?: any, override?: any): Notification;
    create(title?: any, content?: any, type?: NotificationType, override?: any): Notification;
    html(html: any, type?: NotificationType, override?: any, icon?: string): Notification;
    remove(id?: string): void;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值