Get original transcluded content in Angular directive

前端 未结 1 1617
不知归路
不知归路 2021-01-11 09:24

Is it possible to programmatically get the original transcluded content within an Angular.js directive?

I\'m trying to create an an editable directive

1条回答
  •  抹茶落季
    2021-01-11 10:04

    You can use transclude function:

    .directive('editable', function() {
        return {
           transclude: true,
           link: function(scope, element, attrs, ctrl, transclude) {
               transclude(scope, function(clone) {
                   // clone is your transluded content
               });
           }
        };
    });
    

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