Is there a way to load a template within a directive and customize it based on certain attributes provided? How can this be achieved?
Below is the directive in question :
directives.directive("myDirective", function($http, $compile){
return {
restrict: 'E',
scope : {
},
templateUrl: 'lib/directives/myTemplate.html',
link : function(scope, element, attrs) {
// I require the template to include myTemplate.html code, what approach should I take?
var trThead = template.find("thead").find("tr");
var headers = scope.attrs["headers"];
for (var i = 0; i < headers.length; i++) {
trThead.append('<th><span class="th-sort">' + headers[i] + '</span></th>');
}
element.append(template);
}
};
});
I prefer not to directly define the HTML code within my directive due to its extensive nature.