angularJS $on event handler trigger order

前端 未结 6 983
我在风中等你
我在风中等你 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条回答
  •  一整个雨季
    2021-02-01 18:23

    I'm a new user to Angular JS so please forgive if the answer is less than optimal. :P

    If you require the order of the functions triggered by an event to be dependent (i.e., Function A then Function B) then might not creating a trigger function be better?

    function trigger(event,data) {
        FunctionA(event,data);
        FunctionB(event,data);
    }
    
    $rootScope.on('eventTrigger',trigger);
    

提交回复
热议问题