SnackBar

The SnackBarService is a service for displaying snack-bar notifications.

A snack-bar contains always a message. You can optionally add a configuration object in order to show an icon, an action button or deciding how long the snack-bar will be shown. Check the attributes of the snack-bar configuration in the API section of this page.

Example

    import { OSnackBarConfig, SnackBarService } from 'ontimize-web-ngx';

    ...

    export class MyComponent {

        constructor(
            protected snackBarService: SnackBarService
        ) {}

        showSimple() {
            // Simple message
            this.snackBarService.open('Snackbar message');
        }

        showConfigured() {
            // SnackBar configuration
            const configuration: OSnackBarConfig = {
                action: 'Done',
                milliseconds: 5000,
                icon: 'check_circle',
                iconPosition: 'left'
            };

            // Simple message with icon on the left and action
            this.snackBarService.open('Snackbar text', configuration);
        }

    }

Class: OSnackBarConfig

Inputs

Name Description Default

action

string

Text for the action button

icon

string

Name of google icon (see Google material design icons)

iconPosition

left | right

Position of the icon

left

milliseconds

number

Time the snack-bar will be shown

2000

* required inputs.

Updated: