How to pass HTML to angular directive?

后端 未结 1 1302

I am trying to create an angular directive with a template, but I also don\'t want to lose the HTML inside of the div. For example, here is how I would like to call my directiv

相关标签:
1条回答
  • 2021-02-01 02:54

    You'll need to use ng-transclude, add transclude: true in your directive options, and add ng-transclude to your template:

    <div class="example" style="…" ng-transclude></div>`
    

    This plunkr has an example on how to use ng-transclude with a template, to keep the original dom element.

    http://plnkr.co/edit/efyAiTmcKjnhRZMTlNGf

    0 讨论(0)
提交回复
热议问题