angularJS $on event handler trigger order

前端 未结 6 982
我在风中等你
我在风中等你 2021-02-01 17:42

I was wondering two things, in the context of angularJS event handling.

  1. How is defined the order in which handlers listening to the same event are triggered?
6条回答
  •  -上瘾入骨i
    2021-02-01 18:19

    To add another comment on point #2, if you need to guarantee order you could implement an observer pattern using a service with an array of listeners. In the service you can define "addListener" functions that also defines how the listeners are ordered. You can then inject this service into whatever other components need to fire events.

提交回复
热议问题