AngularJS : How does the HTML compiler arrange the order for compiling?

前端 未结 3 1839
孤城傲影
孤城傲影 2021-01-13 22:14

When there are multiple directives across multiple elements on a page, how does Angular\'s HTML compiler arrange the order for compiling?

Say I have the following ma

3条回答
  •  囚心锁ツ
    2021-01-13 22:41

    Regarding multiple directives on one element:

    This is handled using the directive 'priority' property. From the docs: Once all directives for a given DOM element have been identified they are sorted by priority and their compile() functions are executed.

    See http://docs.angularjs.org/guide/directive

    Regarding directive compile order:

    Angular will traverse the DOM - i.e. pick up the elements in the order they appear in the DOM tree. From the docs: Compile: traverse the DOM and collect all of the directives. The result is a linking function.

    See http://docs.angularjs.org/guide/compiler

提交回复
热议问题