[Representation] Begin integration

...of templateLinker into mct-representation. Not working currently
due to prevalence of mct-representation instances with transcluding
directives (hitting a multiple transclusion error.)
This commit is contained in:
Victor Woeltjen
2015-10-28 15:17:36 -07:00
parent 3d59f6df0b
commit ab008ae497
3 changed files with 30 additions and 17 deletions

View File

@ -63,6 +63,7 @@ define(
TemplateLinker.prototype.link = function (scope, element, transclude) {
var originalElement = element,
activeElement = element,
activeTemplateUrl,
self = this;
function removeElement() {
@ -91,13 +92,18 @@ define(
}
}
return function (templateUrl) {
if (templateUrl) {
self.load(templateUrl).then(applyTemplate);
} else {
removeElement();
function changeTemplate(templateUrl) {
if (templateUrl !== activeTemplateUrl) {
if (templateUrl) {
self.load(templateUrl).then(applyTemplate);
} else {
removeElement();
}
activeTemplateUrl = templateUrl;
}
};
}
return changeTemplate;
};
return TemplateLinker;