alfresco-ng2-components/docs/core/notification.service.md
davidcanonieto a6a77b8561 [ADF-3286] Snackbar now supports custom configuration (#3549)
* [ADF-3286] Snackbar now supports custom configuration

* [ADF-3286] Trailing whitespace removed

* [ADF-3286] Tests added

* [ADF-3286] Improved tests

* [ADF-3286] Documentation added

* [ADF-3286]  Logic improved

* [ADF-3286] Styling error fixed

* [ADF-3286] Broken tests fixed

* [ADF-3286] Broken tests fixed
2018-08-14 15:42:12 +01:00

3.6 KiB

Added, Status, Last reviewed
Added Status Last reviewed
v2.0.0 Active 2018-06-08

Notification Service

Shows a notification message with optional feedback.

Notification Service screenshot

Class members

Methods

  • openSnackMessage(message: string = null, config?: number | MatSnackBarConfig = null): MatSnackBarRef<any>
    Opens a SnackBar notification to show a message.
    • message: string - The message (or resource key) to show.
    • config: number - (Optional) Time before notification disappears after being shown or MatSnackBarConfig object to fully customize SnackBar
    • Returns MatSnackBarRef<any> - Information/control object for the SnackBar
  • openSnackMessageAction(message: string = null, action: string = null, config?: number | MatSnackBarConfig = 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
    • config: number - (Optional) Time before notification disappears after being shown or MatSnackBarConfig object to fully customize SnackBar
    • 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');
            });
    }
}
import { NotificationService } from '@alfresco/adf-core';
import { MatSnackBarConfig } from '@angular/material';

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