加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-17 08:50:15 所属栏目:安全 来源:网络整理
导读: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
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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读