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) => NotificationServicesuccess
method
(message: string, translationVars?: { [key: string]: string | number }) => voidDisplay a success toast notification
info
method
(message: string, translationVars?: { [key: string]: string | number }) => voidDisplay an info toast notification
warning
method
(message: string, translationVars?: { [key: string]: string | number }) => voidDisplay a warning toast notification
error
method
(message: string, translationVars?: { [key: string]: string | number }) => voidDisplay an error toast notification
notify
method
(config: ToastConfig) => voidDisplay 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;
}