src/app/modules/shared/services/toaster/toaster.service.ts
Service to show toaster
constructor()
|
Constructor to create injected service(s) object |
InfoToasterCritical |
InfoToasterCritical(title: string, message: string)
|
Returns:
void
|
success |
success(title: string, message: string)
|
Format success message
Parameters :
Returns:
void
|
info |
info(title: string, message: string)
|
Format information message
Parameters :
Returns:
void
|
error |
error(title: string, message: string)
|
Format error message
Parameters :
Returns:
void
|
warning |
warning(title: string, message: string)
|
Format warning message
Parameters :
Returns:
void
|
Private iziToast |
iziToast: |
To show toaster messages |
Private options |
options: |
import { Injectable } from '@angular/core';
/**
* Service to show toaster
*
*/
@Injectable()
export class ToasterService {
/**
* To show toaster messages
*/
private iziToast: any;
private options = {
position: 'topCenter',
titleSize: '18',
timeout: 6000,
transitionIn: 'flipInX',
transitionOut: 'flipOutX'
};
/**
* Constructor to create injected service(s) object
*/
constructor() {
this.iziToast = iziToast; // global object
}
InfoToasterCritical(title: string, message: string) {
iziToast.show({
title: title,
message: message,
class: 'sb-toaster sb-toast-success sb-toast-normal',
position: 'topCenter',
timeout: 6000,
transitionIn: 'flipInX',
transitionOut: 'flipOutX'
});
}
/**
* Format success message
* @memberOf Services.toasterService
* @param {string} message - Success message
*/
success(title: string, message?: string) {
this.iziToast.success({
title: title,
message: message ? message : '',
class: 'sb-toaster sb-toast-normal sb-toast-success',
...this.options
});
}
/**
* Format information message
* @memberOf Services.toasterService
* @param {string} message - Info message
*/
info(title: string, message?: string) {
this.iziToast.info({
title: title,
message: message ? message : '',
class: 'sb-toaster sb-toast-normal sb-toast-info',
...this.options
});
}
/**
* Format error message
* @memberOf Services.toasterService
* @param {string} message - Error message
*/
error(title: string, message?: string) {
this.iziToast.error({
title: title,
message: message ? message : '',
class: 'sb-toaster sb-toast-normal sb-toast-danger',
...this.options
});
}
/**
* Format warning message
* @memberOf Services.toasterService
* @param {string} message - Warning message
*/
warning(title: string, message?: string) {
this.iziToast.warning({
title: title,
message: message ? message : '',
class: 'sb-toaster sb-toast-normal sb-toast-warning',
...this.options
});
}
}