var app = angular.module("app",[]); app.run(["$templateCache", function($templateCache){ $templateCache.put("card.html", '<div class="card"><h1>Personel Kartı</h1><p>Bayram Üçüncü</p></div>'); }]); app.directive("card", ["$templateCache",function($templateCache){ return { restrict: "E", template: $templateCache.get('card.html') } }]);
.card{ border: 2px solid #c54; width: 300px; padding: 15px; } .card h1{ color: #8de; }
<div ng-app="app"> <card></card> </div>