Components: Inject data into an open Snackbar instead of closing and opening it with different content

Created on 3 Nov 2017  路  3Comments  路  Source: angular/components

proposal:
It should be possible to change the Snackbar content while it is open and visible instead of closing it and opening it again with new content

expected behavior:
once an instance of Snackbar is opened and application decided to change the content (for example number of selected items or any other dynamic variable), it should be possible to pass new content and update its content without closing it and opening it again an again

current behavior:
currently if I want to change the content I should use MatSnackBar.open('new message', snackBarConfig) which closes the currently open Snackbar and open it again

use-case or motivation for changing an existing behavior:
Imagine you have a constantly changing variable like line distance on a map and with each user interaction you want to update the measured distance. it is very annoying to open an close each time user change the distance measurements

Most helpful comment

This is already possible with openFromComponent. Just use a service to communicate between with the snackbar component.

https://stackblitz.com/edit/material2-beta12-mlvrtq?file=app%2Fapp.component.ts

All 3 comments

This is already possible with openFromComponent. Just use a service to communicate between with the snackbar component.

https://stackblitz.com/edit/material2-beta12-mlvrtq?file=app%2Fapp.component.ts

Closing as duplicate of #7323

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

julianobrasil picture julianobrasil  路  3Comments

LoganDupont picture LoganDupont  路  3Comments

crutchcorn picture crutchcorn  路  3Comments

RoxKilly picture RoxKilly  路  3Comments

michaelb-01 picture michaelb-01  路  3Comments