多条指令的执行顺序是什么?

What is the order of multiple directives execution?

假设我想创建一个新指令,该指令具有与输入元素交互的隔离作用域,该元素已经具有 ng-model。我如何确定 ng-model 是否会绑定到正确的范围。

<input name="first_input"  type="text"  mydir-mod="compare"  mydir-main ng-model="hi"/>

正如您在此处看到的那样 http://plnkr.co/edit/SGhOSx?p=preview mydir-main 创建隔离范围。 ng-model 会选择绑定哪个作用域?这取决于顺序吗?顺序是如何确定的?为什么 mydir-mod 总是在 mydir-main 之前执行?

有一个priority属性可以设置。

这是文档中的一个片段:

When there are multiple directives defined on a single DOM element, sometimes it is necessary to specify the order in which the directives are applied. The priority is used to sort the directives before their compile functions get called. Priority is defined as a number. Directives with greater numerical priority are compiled first. Pre-link functions are also run in priority order, but post-link functions are run in reverse order. The order of directives with the same priority is undefined. The default priority is 0.