angularjs : how to broadcast between services ? is it possible to broadcast a variable from a service and use it in another service?

StackOverflow https://stackoverflow.com/questions/23653261

  •  22-07-2023
  •  | 
  •  

Вопрос

I'm not so new in angularjs(two week experience). is it possible to broadcast data from a service and use that data in another service. i just want to pass data between services not controller if it's possible. i know it's possible between controllers and from service to controllers .

Это было полезно?

Решение

It should be possible by injecting $rootScope into both services and adding the normal $emit and $on calls. Here is a plunker demonstrating what I mean: http://plnkr.co/edit/6O9qEDCWoauucuDzxygn

This smells like a poor design to me though..

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top