The compilation of the DOM is performed by the call to the $compile()
method. The method traverses the DOM and matches the directives. If a
match is found it is added to the list of directives associated with
the given DOM element. Once all directives for a given DOM element
have been identified they are sorted by priority and their
compile() functions are executed.
ng-repeat指令我相信比自定义指令的优先级低,在某些使用情况下,如dynamic id and custom directive.角允许篡改与指令的优先级选择执行一个前另一个?
angular.module('x').directive('customPriority',function() { return { priority: 1001,restrict: 'E',compile: function () { return function () {...} } } })
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. The order of directives with the same priority is undefined. The default priority is 0.