Shows a notification message with optional feedback.
string
, config?: number|MatSnackBarConfig<Omit<SnackBarData,"actionLabel"|"message">>
, interpolateArgs?: any
): MatSnackBarRef
<any>
string
- The message (or resource key) to show.number|MatSnackBarConfig<Omit<SnackBarData,"actionLabel"|"message">>
- (Optional) Time before notification disappears after being shown or MatSnackBarConfig objectany
- (Optional) The interpolation parameters to add for the translationMatSnackBarRef
<any>
- Information/control object for the SnackBarstring
, action: string
, config?: number|MatSnackBarConfig<Omit<SnackBarData,"actionLabel"|"message">>
, interpolateArgs?: any
): MatSnackBarRef
<any>
string
- The message (or resource key) to show.string
- Caption for the response buttonnumber|MatSnackBarConfig<Omit<SnackBarData,"actionLabel"|"message">>
- (Optional) Time before notification disappears after being shown or MatSnackBarConfig objectany
- (Optional) The interpolation parameters to add for the translationMatSnackBarRef
<any>
- Information/control object for the SnackBarNotificationModel
)NotificationModel
- Notification model to be pushed.string
, action?: string
, interpolateArgs?: any
, showAction: boolean
= true
): MatSnackBarRef
<any>
string
- Text message or translation key for the message.string
- (Optional) Action nameany
- (Optional) The interpolation parameters to add for the translationboolean
- True if action should be visible, false if not. Default: true.MatSnackBarRef
<any>
- string
, action?: string
, interpolateArgs?: any
, showAction: boolean
= true
): MatSnackBarRef
<any>
string
- Text message or translation key for the message.string
- (Optional) Action nameany
- (Optional) The interpolation parameters to add for the translationboolean
- True if action should be visible, false if not. Default: true.MatSnackBarRef
<any>
- string
, action?: string
, interpolateArgs?: any
, showAction: boolean
= true
): MatSnackBarRef
<any>
string
- Text message or translation key for the message.string
- (Optional) Action nameany
- (Optional) The interpolation parameters to add for the translationboolean
- True if action should be visible, false if not. Default: true.MatSnackBarRef
<any>
-The Notification Service is implemented on top of the Angular Material Design snackbar. Use this service to show a notification message, and optionally get feedback from it.
import { NotificationService } from '@alfresco/adf-core';
class MyComponent implements OnInit {
constructor(private notificationService: NotificationService) {
}
ngOnInit() {
this.notificationService
.openSnackMessage('test', 200000)
.afterDismissed()
.subscribe(() => {
console.log('The snack-bar was dismissed');
});
}
}
import { NotificationService } from '@alfresco/adf-core';
class MyComponent implements OnInit {
constructor(private notificationService: NotificationService) {
}
ngOnInit() {
this.notificationService
.openSnackMessageAction('Do you want to report this issue?', 'send', 200000)
.afterDismissed()
.subscribe(() => {
console.log('The snack-bar was dismissed');
});
}
}
import { NotificationService } from '@alfresco/adf-core';
import { MatSnackBarConfig } from '@angular/material/snackbar';
class MyComponent implements OnInit {
snackBarConfig: MatSnackBarConfig = new MatSnackBarConfig();
constructor(private notificationService: NotificationService) {
}
ngOnInit() {
this.notificationService
.openSnackMessageAction('Do you want to report this issue?', 'send', snackBarConfig)
.afterDismissed()
.subscribe(() => {
console.log('The snack-bar was dismissed');
});
}
}
By providing a decorativeIcon
property in the SnackBarData
, it is possible to render a decorative
MaterialIcon
to the left of the message.
import { NotificationService } from '@alfresco/adf-core';
import { MatSnackBarConfig } from '@angular/material/snackbar';
class MyComponent implements OnInit {
snackBarConfig: MatSnackBarConfig = new MatSnackBarConfig();
constructor(private notificationService: NotificationService) {
}
ngOnInit() {
this.snackBarConfig.data = { decorativeIcon: 'folder' };
this.notificationService
.openSnackMessageAction('Do you want to report this issue?', 'send', snackBarConfig)
.afterDismissed()
.subscribe(() => {
console.log('The snack-bar was dismissed');
});
}
}
The default message duration is 5000 ms that is used only if you don't pass a custom duration in the parameters of openSnackMessageAction/openSnackMessage methods. You can also change the default 5000 ms adding the following configuration in the app.config.json:
"notificationDefaultDuration" : "7000"
Name | Description |
---|---|
info | To notify messages. It will be displayed with an info icon next to it. |
warn | To notify warning messages. It will be displayed with a warning icon next to it. |
error | To notify errors. It will be displayed with an error icon next to it. |
recursive | To notify recursive messages. If a message is prompt to duplicate an existing notification and you don't want to overload the notification history component with the same message use the recursive type. I.e. notifications coming from an API call that are triggered every time a component is initialized. It will be displayed with an info icon next to it. |
© 2023 Alfresco Software, Inc. All Rights Reserved.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.