This is the directive that I wanna build:
module.directive('templater', function () {
return {
restrict: 'A',
replace: true,
templateUrl: function (element, attrs) {
return attrs.templater;
}
};
});
but, as you may know, in this HTML:
<div
ng-repeat="item in items"
templater="item.template">
</div>
accessing attrs.templater
simply gives item.template
instead of the actual template url string.
How do you access the data inside attrs.templater
without going inside the linking function?
I want to leverage the simplicity of the templateUrl
function, also, avoid the reflow overhead in the linking function.
EDITED: My original assumption was wrong.
Since
item.template
is meaningful only in the context of a scope and since the template-fetching/compiling happens at a point in time when there is no info regarding scopes there doesn't seem to be a way to fetch the template prior to the linking phase.