Skip to content
Advertisement

Call javascript function when closing ngbdropdownmenu angular

I am implementing an alert/notification dropdown in my angular app. I have got the alerts to display when clicking on the icon, however I am now trying to update the ones that have been read (unread are shown in bold).

For example, when opening the app, it might show the number 2 on the icon (as 2 alerts are unread). When the notification icon is clicked and the alert menu is shown, then closed (or clicked off), i want to change them all to read by calling a function, and then remove the number 2 on the alerts icon by updating the div (is there a way to do this without refreshing the whole page?). Does anyone know how i can do this?

Thanks in advance!

Below if my code so far:

JavaScript

Advertisement

Answer

A ngbDropDownMenu has a method openChange (see the “Outputs” in the doc -the outputs are the “events” you can capture-)

Some like

JavaScript

execute a function defined in your .ts

JavaScript

You can also, if only interesting in close make some like

JavaScript

The function “close” only execute when $event is false -when is closed-

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement