How to use `replace` of directive definition?

后端 未结 4 1891
执笔经年
执笔经年 2020-12-02 09:27

In this document: http://docs.angularjs.org/guide/directive , it says that there is a replace configuration for directives:

templ

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-02 10:28

    You are getting confused with transclude: true, which would append the inner content.

    replace: true means that the content of the directive template will replace the element that the directive is declared on, in this case the

    tag.

    http://plnkr.co/edit/k9qSx15fhSZRMwgAIMP4?p=preview

    For example without replace:true

    directive template1

    and with replace:true

    directive template1
    

    As you can see in the latter example, the div tag is indeed replaced.

提交回复
热议问题