I´m trying to create a directive in AngularJS for a small templating issue. In my HTML-File I have this:
<div myinclude="header.tpl.html"></div>
My directive should transform this to that:
<div>{content of file: header.tpl.html}</div>
This is how far (or not) I´ve come, but I guess, I´m missing a piece:
myApp.directive('myinclude', function () {
return {
compile: function compile( tElement, tAttributes ) {
console.log(tAttributes.myinclude); // logs filename
return {
templateURL: tAttributes.myinclude
};
}
};
});
Has anyone done something like this before, and is willing to share?