I am using socket.io to enable chat in my app and i am using a service SocketService
to perform all the socket stuff. When a message came then i want to trigger
I realize this post is old but I'd like to give my two cents after dealing with Angular JS for several years. I personally would reconsider this approach. Ideally with AngularJS you'd modify your controller/directive to facilitate transferring data to the view model and ultimately bind an HTML template to what I call "the user friendly" view model. This view model should simply reflect what you want the user to see and when in general. Using this method the moment connect
event happens your view model which should be bound to the service's data will reflect changes to the data the moment the data arrives.