angularjs - Wrapper directive and class duplication -
angularjs - Wrapper directive and class duplication -
i want create directive wrap element. i've tried one:
.directive('wrap', function() { homecoming { restrict: 'a', replace: true, transclude: 'element', template: '<div class="wrapper" ng-transclude></div>' }; });
but when utilize it:
<a class="my-class" wrap>hello</a>
i'm getting my-class
duplicated:
<div class="my-class wrapper" ng-transclude="" wrap=""> <a class="my-class ng-scope" wrap="">hello</a> </div>
what want without my-class
in wrapper div:
<div class="wrapper" ng-transclude="" wrap=""> <a class="my-class ng-scope" wrap="">hello</a> </div>
is possible?
you ca tranclude: true:
app.directive('wrap', function() { homecoming { restrict: 'a', replace: true, transclude: true, template: '<div class="wrapper" ng-transclude></div>' }; });
html:
<div wrap><a class="my-class">hello</a></div>
or (if utilize restrict:'e'):
<wrap><a class="my-class">hello</a></wrap>
output:
<div class="wrapper" ng-transclude="" wrap=""> <a class="my-class ng-scope">hello</a> </div>
http://plnkr.co/edit/bxeeo4lytcicoxe65mu9?p=preview
angularjs angularjs-directive
Comments
Post a Comment