Understanding the transclude option of directive definition?

后端 未结 6 1531
醉话见心
醉话见心 2020-12-02 03:28

I think this is one of the hardest concept for me to understand with angularjs\'s directive.

The document from http://docs.angularjs.org/guide/directive says:

<
6条回答
  •  甜味超标
    2020-12-02 04:25

    From Wiki:

    "In computer science, transclusion is the inclusion of part or all of an electronic document into one or more other documents by reference."

    I'd like to add another use for transclusion, and that is that it changes the execution order of the compile and link functions of parent and child directives. This can be useful when you want to compile the child DOM before the parent DOM as the parent DOM perhaps depends on the child DOM. This article goes more in depth and clarifies it very well!

    http://www.jvandemo.com/the-nitty-gritty-of-compile-and-link-functions-inside-angularjs-directives-part-2-transclusion/

提交回复
热议问题