Configuration
SnotifyToastConfig- changes toasts configuration.SnotifyGlobalConfig- changes toast dock configuration.
Setting default configuration
Default configuration looks like this - toastDefaults
Of course you can use it like json, just omit imports, and replaceSnotifyStyle&SnotifyPositionwith string values. Just be sure that you are follow SnotifyDefaults interface.
You should initializeng-snotifywith default configuration object.
We provide it by custom object injection{ provide: 'SnotifyToastConfig', useValue: ToastDefaults}by default.
Example
import {SnotifyModule, SnotifyService, ToastDefaults} from 'ng-snotify';
@NgModule({
declarations: [
AppComponent
],
imports: [
SnotifyModule
],
providers: [
{ provide: 'SnotifyToastConfig', useValue: ToastDefaults},
SnotifyService
],
bootstrap: [AppComponent]
})
export class AppModule { }
If you want to change default config in runtime you can use service.setDefaults() method
SnotifyToastConfig
timeout
- type:
number - default:
2000Toast timeout in milliseconds. 0 - Disable timeout
showProgressBar
- type:
boolean - default:
trueEnable/Disable progress bar. Disabled by default if timeout is 0.
type
- type: SnotifyType
Depends on toast type - success | async | error | etc... Actually it changes only toast class name
closeOnClick
- type:
boolean - default:
trueEnable/Disable close action by clicking on toast
pauseOnHover
- type:
boolean - default:
trueEnable/Disable pause on hover action
buttons
- type: SnotifyButton[]
- default:
[ {text: 'Ok', action: null, bold: true}, {text: 'Cancel', action: null, bold: false}, ]Buttons config for Confirmation & Prompt types You can pass, unlimited number of buttons. Just be sure you can handle it)
placeholder
- type:
string - default:
"Enter answer here..."Placeholder for Prompt toast
titleMaxLength
- type:
number - default:
16Toast title maximum length
bodyMaxLength
- type:
number - default:
150Toast body maximum length
icon
- type:
string - default:
nullCustom icon url.
const icon = `https://placehold.it/48x100`; vm.$snotify.simple('Example body', null, { icon: icon });
iconClass
- type:
string - default:
nullCustom icon class.
backdrop
- type:
number - default:
-1Backdrop opacity in range from
0.0to1.0. Disabled-1
animation
- type: SnotifyAnimate
- default:
{enter: 'fadeIn', exit: 'fadeOut', time: 400}```Animation configuration object. Time in milliseconds
html
- type:
string - default:
nullToast inner html. When set, overrides toast content.
position
- type: SnotifyPosition
- default:
rightBottomToasts position on screen
SnotifyGlobalConfig
maxOnScreen
- type:
number - default:
8Max toast items on screen.
For example you want to display 3 toasts max at the time. But for some purposes your system calls it 10 times.
With this option, 8 toast will be shown. And after each of it will disappear, new toast from the queue will be shown.
maxAtPosition
- type:
number - default:
8Max toast items at position.
Same asmaxOnScreenbut affects only current toast position block.
newOnTop
- type:
true - default:
150Should new items come from top or bottom side.
This option created for styling purposes.
For example, if your toast position is TOP-RIGHT. It's not very nice, when items comes from top and pulls down all other toasts