Browse Source

feat(theme-shared): add clear toasts by key functionality

related issue: #2537
pull/2606/head
TheDiaval 7 years ago
parent
commit
72fee038a5
  1. 6
      npm/ng-packs/packages/theme-shared/src/lib/services/toaster.service.ts

6
npm/ng-packs/packages/theme-shared/src/lib/services/toaster.service.ts

@ -71,7 +71,7 @@ export class ToasterService {
message, message,
title, title,
severity, severity,
options: { closable: true, ...options, id }, options: { closable: true, id, ...options },
}); });
this.toasts$.next(this.toasts); this.toasts$.next(this.toasts);
return id; return id;
@ -89,8 +89,8 @@ export class ToasterService {
/** /**
* Removes all open toasts at once. * Removes all open toasts at once.
*/ */
removeAll() { clear(key?: string) {
this.toasts = []; this.toasts = !key ? [] : this.toasts.filter(toast => toast.options.containerKey !== key);
this.toasts$.next(this.toasts); this.toasts$.next(this.toasts);
} }
} }

Loading…
Cancel
Save