Listen to window events in an Angularjs service

后端 未结 4 2253
梦谈多话
梦谈多话 2020-12-17 23:21

I want to listen to the window events in my AngularJS service so that I can broadcast them to my controllers.

I have a Chrome extension which sends any message using

4条回答
  •  半阙折子戏
    2020-12-17 23:37

    Do you inject that service somewhere? Services will run only if you really injects them.

    Additionally, it's better to use $window instead of window, so you'll be able to mock it later in your tests.

提交回复
热议问题