Close snackbar upon navigating to another page?

1 Answer 44 Views
Notification
Caroline
Top achievements
Rank 1
Caroline asked on 24 Jan 2024, 06:41 PM | edited on 24 Jan 2024, 06:42 PM

Hi there,

Is there any built-in way to close a snackbar/notification bar if the user navigates to another page?

Or, if this isn't the right use case for the notification bar, could someone point me to a better one?

Thank you!

1 Answer, 1 is accepted

Sort by
0
Zornitsa
Telerik team
answered on 26 Jan 2024, 04:08 PM

Hi Caroline,

The Notification component can be closed programmatically by utilizing a NotificationRef instance, and then using its built-in hide() methodIn your case, this method can be called when the corresponding navigation, with which you desire to hide the Notification, is performed.

On the other hand, if the Notification is initialized in a component that is being destroyed with the navigation, the developer may call the hide() function in the ngOnDestroy() method of the respective component.

Another approach that may be suitable for your scenario is appending the Notification to a dynamic container that is destroyed at some point either through the route navigation, or by the application logic. More information regarding this approach and a runnable example is available in the following article:

I hope that the provided suggestions are helpful. Let me know if you have any further questions on this matter.

Regards,
Zornitsa
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources
Tags
Notification
Asked by
Caroline
Top achievements
Rank 1
Answers by
Zornitsa
Telerik team
Share this question
or