Angular Notifier is a custom alert notification library which can be used to display alert snackbar to the application.
Start by installing the Angular library from npm
npm i @codex-lab/notifier
@import '~@angular/material/prebuilt-themes/indigo-pink.css';
The following css statement should be added the style.scss
to allow notification to overlay on
the page. For more info, follow
pre-built-theme in angular project
Next, you'll need to import the following module in your app's module.
import {NotifierModule} from "@codex-lab/notifier";
@NgModule({
...
imports: [ NotifierModule ],
...
});
After required module is configured, you can directly inject the service it provides into the Angular Component to utilise the library
@Component({
...
})
export class AppComponent {
...
constructor(private notifierService: NotifierService) {
}
...
}
The NotifierService provides the following functions to generate notification
interface NotifierService {
showNotificationV1(messageList: string[], status: boolean, title?: string): void;
showNotificationV2(messageList: string[], status: NotificationStatus, title?: string): void;
getNotifierDuration(status: NotificationStatus): number;
}
The Service utilises an enum constant to provide the following NotificationStatus
export enum NotificationStatus {
SUCCESS = 0,
FAILED = 1,
WARNING = 2,
ERROR = 3,
INFO = 4
}