alfresco-ng2-components/docs/core/notification.service.md
Denys Vuika 2f51b9f2b8 [ADF-3118] translation support for notification service (snackbars) (#3427)
* translation support for snackbar

* unit tests
2018-06-04 10:58:21 +02:00

2.3 KiB

Added, Status
Added Status
v2.0.0 Active

Notification Service

Shows a notification message with optional feedback.

Notification Service screenshot

Class members

Methods

  • openSnackMessage(message: string = null, millisecondsDuration?: number = null): MatSnackBarRef<any>
    Opens a snackbar notification to show a message.
    • message: string - The message (or resource key) to show.
    • millisecondsDuration: number - (Optional) Time before notification disappears after being shown
    • Returns MatSnackBarRef<any> - Information/control object for the snackbar
  • openSnackMessageAction(message: string = null, action: string = null, millisecondsDuration?: number = null): MatSnackBarRef<any>
    Opens a snackbar notification with a message and a response button.
    • message: string - The message (or resource key) to show.
    • action: string - Caption for the response button
    • millisecondsDuration: number - (Optional) Time before the notification disappears (unless the button is clicked)
    • Returns MatSnackBarRef<any> - Information/control object for the snackbar

Details

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';

export 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';

export 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');
            });
    }
}