mirror of
https://github.com/nasa/openmct.git
synced 2025-06-14 13:18:15 +00:00
[Representation] Provide initial templates
...to avoid temporarily replacing with a comment when this is not needed.
This commit is contained in:
@ -58,10 +58,14 @@ define(
|
|||||||
var templateMap = {};
|
var templateMap = {};
|
||||||
|
|
||||||
function link(scope, element) {
|
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) {
|
scope.$watch('key', function (key) {
|
||||||
changeTemplate(templateMap[key]);
|
changeTemplate(key && templateMap[key]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ define(
|
|||||||
* @returns {Function} a function which can be called with a template
|
* @returns {Function} a function which can be called with a template
|
||||||
* URL to switch templates, or `undefined` to remove.
|
* URL to switch templates, or `undefined` to remove.
|
||||||
*/
|
*/
|
||||||
TemplateLinker.prototype.link = function (scope, element) {
|
TemplateLinker.prototype.link = function (scope, element, templateUrl) {
|
||||||
var activeElement = element,
|
var activeElement = element,
|
||||||
activeTemplateUrl,
|
activeTemplateUrl,
|
||||||
comment = this.$compile('<!-- hidden mct element -->')(scope),
|
comment = this.$compile('<!-- hidden mct element -->')(scope),
|
||||||
@ -125,7 +125,11 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
removeElement();
|
if (templateUrl) {
|
||||||
|
changeTemplate(templateUrl);
|
||||||
|
} else {
|
||||||
|
removeElement();
|
||||||
|
}
|
||||||
|
|
||||||
return changeTemplate;
|
return changeTemplate;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user