Skip to content Skip to sidebar Skip to footer

Get Original Transcluded Content In Angular Directive

Is it possible to programmatically get the original transcluded content within an Angular.js directive? I'm trying to create an an editable directive which can be added to any div

Solution 1:

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
           });
       }
    };
});

Post a Comment for "Get Original Transcluded Content In Angular Directive"