Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ngx-notifier

sibiraj-s2kMIT13.0.0TypeScript support: included

A Simple Notification Service for Angular Applications

notifier, angualr

readme

angular

NgxNotifier

A Simple Notification Service for Angular Applications

Tests Status npm version npm downloads license

Getting Started

ngx-notifier is a simple notification service for Angular applications and is meant to be simple with limited features.

If you are looking for angularjs(1.x) version, Try angularjs-toast

Installation

Install via Package managers such as npm or yarn

npm install ngx-notifier --save
# or
yarn add ngx-notifier

Usage

Import provideAnimations in your app.config to enable required animations

import { ApplicationConfig } from '@angular/core';
import { provideAnimations } from '@angular/platform-browser/animations';

export const appConfig: ApplicationConfig = {
  providers: [provideAnimations()],
};

Then, import NgxNotifierComponent in your app.component.ts

import { NgxNotifierComponent, NgxNotifierService } from 'ngx-notifier';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [NgxNotifierComponent],
  templateUrl: './app.component.html',
})
export class AppComponent {
  constructor(private ngxNotifierService: NgxNotifierService) {}

  createNotification() {
    this.ngxNotifierService.createToast(message, style, duration);
  }
}

Then, add the ngx-notifier component in your app.component.html

<ngx-notifier></ngx-notifier>

Create a toast

this.ngxNotifierService.createToast(message, style, duration);
  • message message to be sent as notification
  • style notification style, which can be the following success|danger|warning|info. Default is info
  • duration in milliseconds, timeout for the notification

Clear all toasts

this.ngxNotifierService.clear();

Clear the last toast

this.ngxNotifierService.clearLast();

Notifier Component

Notifier component accepts

<ngx-notifier
  [allowDuplicates]="true"
  [allowHTML]="false"
  [className]="myCustomClassName"
  [duration]="5000"
  [disableAnimations]="false"
  [dismissOnClick]="false"
  [insertOnTop]="true"
  [max]="5"
>
</ngx-notifier>
  • allowDuplicates: whether to allow duplicate messages in notifications
  • allowHTML whether to allow or display HTML as it is, HTML will be sanitized and any JS will be maked as unsafe.
  • className custom class for notifications
  • disableAnimations whether to enable or disable animations for the toast.
  • dismissOnClick: dismiss notification on click
  • duration time in milliseconds for dismissing notifications, default is 60s
  • insertOnTop whether to insert notification on top or bottom
  • max: maximum number of notifications to be displayed

Demo

Demo at stackblitz ngx-notifier

changelog

CHANGELOG

All notable changes to this project will be documented in this file.

Tags

  • Features
  • Bug Fixes
  • Performance Improvements
  • Dependency Updates
  • Breaking Changes
  • Documentation
  • Internal

v13.0.0 (2024-05-11)

Breaking Changes

  • export component as standalone component (e764ddd)

v12.0.0 (2024-03-05)

Breaking Changes

  • requires angular 17 or greater (af7294e)

v11.0.0 (2023-07-01)

Breaking Changes

  • requires angular 16 or greater (b22735f)

v10.0.0 (2022-12-23)

Breaking Changes

  • requires angular 15 or greater (322552f)

v9.0.0 (2022-08-14)

Breaking Changes

  • requires angular 14 or greater (40789f1)

v8.0.0 (2022-01-15)

Breaking Changes

  • requires angular 13 or greater (cbb1ecb)

Internal

v7.0.0 (2021-05-29)

Breaking Changes

  • requires angular 12 or greater (2c18e0f)
  • bootstrap is no longer a dependency (2c0750c)

v6.0.0 (2020-10-28)

Features

v5.0.2 (2020-04-26)

Dependency Updates

  • update peerDependencies (44a6c71)

v5.0.1 (2020-04-25)

Documentation

Internal

  • fix invalid test file path in tsconfig (ba5ef90)

v5.0.0 (2020-04-25)

Features

  • fix compatibility issues with ivy compiler (e00de3f)

v4.0.0 (2020-02-29)

Features

v3.0.0 (2020-01-04)

Breaking Changes

  • app-ngx-paginator is renamed to ngx-paginator (78cb12f)

Features

Dependency updates

Internal

  • add prepublish script to prevent accidental publish to npm registry. (c8ce414)
  • migrate to github-actions from travis-ci (d3cac9d)

Documentation

  • use gh-pages branch to publish documentation (f51aca4)

v2.0.2 (2018-09-24)

Internal

v2.0.1 (2018-09-22)

Documentation

  • recompiled documentation for latest changes which also includes CHANGELOG (676d35a)

Internal

  • fix end-to-end tests (06899a8)
  • migrate from travis-ci.org to travis-ci.com
  • removed vscode settings in favour of editorconfig (25e54df)

v2.0.0 (2018-09-22)

Upgrade to Angular 6

Dependency updates

  • update angular dependencies (c7e796f)
  • update ng-packager to support angular v6 (c7e796f)
  • update compodoc to v1.1.5 (c7e796f)

v1.3.1 (2018-06-28)

Dependency Updates

v1.3.0 (2018-04-09)

Features

  • option to disable animations (a07500c)

Bug Fixes

  • no animation while closing a toast (a07500c)

Internal

  • ci: expect files to have angular-whitespace (1c13ff3)

Dependency Updates

  • update ng-packagr to v2.4.2 (a74d48b)

v1.2.1 (2018-04-05)

Performance Improvements

  • revert: don't expose internal variables (48c57e6)
  • add @angular/platform-browser as peerDependency (13f930e)

Dependency Updates

  • update tsickle devDependency (94e816a)

v1.2.0 (2018-04-04)

Features

  • allow HTML tags in notifications (5ea41f3)

Bug Fixes

  • click events not triggered if HTML tags are used (d34eb10)
  • don't expose internal variables (56fc4e4)

v1.1.0 (2018-04-04)

Features

  • clear all notifications at once (7c9c011)
  • clear last notification (95c9100)
  • insert toast message on top or bottom (91983ca)

v1.0.0 (2018-04-03)

Initial Release. A Simple Notification service for Angular application