angularjs – 什么是ng-repeat指令的“优先级”可以改变它?

Angular文档说:

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.角允许篡改与指令的优先级选择执行一个前另一个

是的,您可以设置指令的优先级。 ng-repeat的优先级为 1000,实际上高于自定义指令(认优先级为0)。您可以使用此号码作为指南,了解如何在您的指令上设置您自己的优先级。
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.

相关文章

ANGULAR.JS:NG-SELECTANDNG-OPTIONSPS:其实看英文文档比看中...
AngularJS中使用Chart.js制折线图与饼图实例  Chart.js 是...
IE浏览器兼容性后续前言 继续尝试解决IE浏览器兼容性问题,...
Angular实现下拉菜单多选写这篇文章时,引用文章地址如下:h...
在AngularJS应用中集成科大讯飞语音输入功能前言 根据项目...
Angular数据更新不及时问题探讨前言 在修复控制角标正确变...