bootstrap-toast
v1.0.13
Published
Simple toast library for Angular 2+ with Bootstrap 4. See [this demo](https://bootstrap-toast-example.web.app/) and try options.
Downloads
13
Readme
BootstrapToast for Angular 2+
Simple toast library for Angular 2+ with Bootstrap 4. See this demo and try options.
Requirements
Must be install the following npm packages:
- bootstrap
Installation
npm install --save bootstrap-toast
Import bootstrap-toast
module your ngModule.
Paste the following code the end of the app.component.html file:
<lib-bootstrap-toast [config]="config"></lib-bootstrap-toast>
The config parameter is optional but if you want to modify default config, you use the following format:
{
"position": "top-right", // or top-left, bottom-left, bottom-right
"autoclose": true, // true or false
"delay": 3 // seconds
}
The following example shows how to create a toast notification programatically. The function returns Subject instance. If the notification has one or more buttons, you can subscribe this instance to catch button actions.
this.toast.create( {
"title": "Message",
"message": "This is Sparta!",
"buttons": [
{
"label": "OK",
"action": "ok",
"class": "btn-primary"
},
{
"label": "Cancel",
"action": "cancel",
"class": "btn-light"
}
]
} ).subscribe(action => { ... })
Thats all.