Skip to content

Instantly share code, notes, and snippets.

@csvan
Created October 27, 2015 09:21
Show Gist options
  • Select an option

  • Save csvan/48ca3949c9ce25769731 to your computer and use it in GitHub Desktop.

Select an option

Save csvan/48ca3949c9ce25769731 to your computer and use it in GitHub Desktop.

Revisions

  1. csvan created this gist Oct 27, 2015.
    14 changes: 14 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    .directive('dynamicDirective', function ($compile) {
    return {
    restrict: 'E',
    replace: true,
    scope: {
    directiveName: '@',
    directiveParams: '='
    },
    link: function ($scope, $element, $attr) {
    // Dynamically construct the directive
    $element.append($compile(`<${directiveName} parameters="directiveParams"> <${directiveName}/>`)($scope));
    }
    }
    })