Skip to main content

NotificationService

NotificationService​

Provides toast notification functionality.

Example

class MyComponent {
constructor(private notificationService: NotificationService) {}

save() {
this.notificationService
.success(_('asset.notify-create-assets-success'), {
count: successCount,
});
}
}

```ts title="Signature"
class NotificationService {
constructor(i18nService: I18nService, resolver: ComponentFactoryResolver, overlayHostService: OverlayHostService)
success(message: string, translationVars?: { [key: string]: string | number }) => void;
info(message: string, translationVars?: { [key: string]: string | number }) => void;
warning(message: string, translationVars?: { [key: string]: string | number }) => void;
error(message: string, translationVars?: { [key: string]: string | number }) => void;
notify(config: ToastConfig) => void;
}

constructor​

method
(i18nService: I18nService, resolver: ComponentFactoryResolver, overlayHostService: OverlayHostService) => NotificationService

success​

method
(message: string, translationVars?: { [key: string]: string | number }) => void

Display a success toast notification

info​

method
(message: string, translationVars?: { [key: string]: string | number }) => void

Display an info toast notification

warning​

method
(message: string, translationVars?: { [key: string]: string | number }) => void

Display a warning toast notification

error​

method
(message: string, translationVars?: { [key: string]: string | number }) => void

Display an error toast notification

notify​

method
(config: ToastConfig) => void

Display a toast notification.

NotificationType​

The types of notification available.

Signature
type NotificationType = 'info' | 'success' | 'error' | 'warning'

ToastConfig​

Configuration for a toast notification.

Signature
interface ToastConfig {
message: string;
translationVars?: { [key: string]: string | number };
type?: NotificationType;
duration?: number;
}

message​

property
string

translationVars​

property
{ [key: string]: string | number }

type​

duration​

property
number