var app = angular.module('app', []); app.controller('appController', function ($scope) {}); app.directive('classDirective', function () { return { restrict: 'C', transclude: true, template: '<div class="target">classDirective example - <span ng-transclude></span></div>' }; });
<section ng-app="app" class="container"> <section ng-controller="appController"> <div class="not-target classDirective">text</div> </section> </section>
.target { width: 100px; height: 100px; border-radius: 5%; margin: 30px; padding: 20px; background: #00a; text-align: center; color: #fff; }