diff --git a/platform/representation/src/MCTInclude.js b/platform/representation/src/MCTInclude.js index d56d2f0e69..c7b3c9a3ed 100644 --- a/platform/representation/src/MCTInclude.js +++ b/platform/representation/src/MCTInclude.js @@ -58,10 +58,14 @@ define( var templateMap = {}; function link(scope, element) { - var changeTemplate = templateLinker.link(scope, element); + var changeTemplate = templateLinker.link( + scope, + element, + scope.key && templateMap[scope.key] + ); scope.$watch('key', function (key) { - changeTemplate(templateMap[key]); + changeTemplate(key && templateMap[key]); }); } diff --git a/platform/representation/src/TemplateLinker.js b/platform/representation/src/TemplateLinker.js index cb4f616adb..e2b9f42155 100644 --- a/platform/representation/src/TemplateLinker.js +++ b/platform/representation/src/TemplateLinker.js @@ -72,7 +72,7 @@ define( * @returns {Function} a function which can be called with a template * URL to switch templates, or `undefined` to remove. */ - TemplateLinker.prototype.link = function (scope, element) { + TemplateLinker.prototype.link = function (scope, element, templateUrl) { var activeElement = element, activeTemplateUrl, comment = this.$compile('')(scope), @@ -125,7 +125,11 @@ define( } } - removeElement(); + if (templateUrl) { + changeTemplate(templateUrl); + } else { + removeElement(); + } return changeTemplate; };