@kovalenko/snack-bar
v1.0.3
Published
This module provides a service to open Material Snackbar with default dismiss action.
Downloads
3
Readme
Material Snackbar with default action
This module provides a service to open Material Snackbar with default dismiss action.
Installation
npm install @kovalenko/snack-bar
Usage
First, import the SnackBarModule to your module:
import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {SnackBarModule} from '@kovalenko/snack-bar';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {DialogComponent} from './app';
@NgModule({
imports: [BrowserModule, SnackBarModule],
declarations: [DialogComponent],
bootstrap: [DialogComponent],
})
export class AppModule { }
platformBrowserDynamic().bootstrapModule(DialogComponent);
Then inject SnackBarService:
import {Component} from '@angular/core';
import {SnackBarService, snack} from 'snack-bar';
@Component({
template: ``
})
export class DialogComponent {
constructor(
private readonly snackBarService: SnackBarService,
) { }
ngOnInit(): void {
// Set default action title globally
this.snackBarService.defaultAction = 'Close';
// Launch snackbar
this.snackBarService.open('Privet', snack.error);
}
}
API
SnackBarService
Properties
defaultAction?: string;