src/app/shared/services/toast.service.ts
Toast Service
Properties |
Methods |
| remove | ||||
remove(toast)
|
||||
|
Defined in src/app/shared/services/toast.service.ts:16
|
||||
|
Parameters :
Returns :
void
|
| show | ||||||||||||
show(textOrTpl: string | TemplateRef
|
||||||||||||
|
Defined in src/app/shared/services/toast.service.ts:12
|
||||||||||||
|
Parameters :
Returns :
void
|
| showError | ||||||||||||
showError(message: string, args: object)
|
||||||||||||
|
Defined in src/app/shared/services/toast.service.ts:29
|
||||||||||||
|
Parameters :
Returns :
void
|
| showSuccess | ||||||||||||
showSuccess(message: string, args: object)
|
||||||||||||
|
Defined in src/app/shared/services/toast.service.ts:20
|
||||||||||||
|
Parameters :
Returns :
void
|
| toasts |
Type : any[]
|
Default value : []
|
|
Defined in src/app/shared/services/toast.service.ts:10
|
import {Injectable, TemplateRef} from '@angular/core';
/**
* Toast Service
*/
@Injectable({
providedIn: 'root'
})
export class ToastService {
toasts: any[] = [];
show(textOrTpl: string | TemplateRef<any>, options: any = {}) {
this.toasts.push({ textOrTpl, ...options });
}
remove(toast) {
this.toasts = this.toasts.filter(t => t !== toast);
}
showSuccess(message: string,
args = {
classname: 'bg-success text-light',
delay: 2000 ,
autohide: true
}) {
this.show(message, args);
}
showError(
message: string,
args = {
classname: 'bg-danger text-light',
delay: 2000 ,
autohide: true,
}) {
this.show(message, args);
}
// showCustomToast(customTpl) {
// this.show(customTpl, {
// classname: 'bg-info text-light',
// delay: 3000,
// autohide: true
// });
// }
}