Is there a way to listen to angular events like routechangestart from outside, like from browser console or an add on?

I want to listen to routechangestart event of my application from browser console or inside a browser extension. Is there a way to do this? I haven’t tried anything yet because I have little knowledge about how Angular works. I want this to notify the user whenever a view is changed.

Any help is appreciated.

Answer

Well you want some code to be executed from console at state change events, you could use something like:

angular.element(document).scope().   $on("$stateChangeStart",function(){//your code here
}

Just change the event name from $stateChangeStart to whatever event you want to listen to

Leave a Reply

Your email address will not be published. Required fields are marked *