PrashantLearnIT
Tera Sage

Hello Everyone,

 

You can use $rootScope.$broadcast to notify other widgets and $rootScope.$on to receive the notification

FIRING AN EVENT:

Go to your desired widget and on the client controller do something like this

PrashantLearnIT_0-1716355932521.png

 

PrashantLearnIT_1-1716355932527.png

 

TIPS:

  • It is also great if you will put a 500 milliseconds timeout to broadcast just to ensure that all other widgets are loaded and ready to listen when we broadcast an event.
  • Event name can be anything you want just come up on a name with a unique identifier
  • Data can also be a JSON object. For this case, it’s just a string.

LISTENING TO AN EVENT

Go to your next widget where you want to listen on the event that you created, and do something like this

PrashantLearnIT_2-1716355932531.png

 

This can be very useful when you want to send data to other widgets.

 

If my content helped you in anyway, please mark this content as BOOKMARK, SUBSCRIBE & HELPFUL

 

Best Regards,

Prashant Kumar (LearnIT)

 

YouTube Channel LearnIT: https://www.youtube.com/@learnitwithprashant

Blog LearnIT: https://medium.com/@LearnITbyPrashant

Prashant Kumar LinkedIn: https://www.linkedin.com/in/learnitbyprashant/

ServiceNow Community Prashant Kumar - https://www.servicenow.com/community/user/viewprofilepage/user-id/19635