Skip to content

snack bar: change background color #2980

Closed
@constantinlucian

Description

@constantinlucian

I use snack-bar to show notifications. I want to change background color when the response is: error (background: red) or success(background : green).

Code:
let config = new MdSnackBarConfig();
config.duration = 500;
snackBarRef = this.snackBar.open("Message", "", config);

snackBarRef.afterOpened().subscribe(()=>{ });
snackBarRef.afterDismissed().subscribe(()=>{ });

I tried to use:
let snackContainer = document.getElementById("cdk-overlay-0");
snackContainer.firstElementChild.setAttribute("style","background-color:red");
but the snack-bar disappear.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions