[Representation] Don't reuse scopes

Addresses 
This commit is contained in:
Victor Woeltjen 2015-10-30 15:06:51 -07:00
parent ec56fe7bfd
commit a45dfc3822

View File

@ -92,10 +92,19 @@ define(
var activeElement = element, var activeElement = element,
activeTemplateUrl, activeTemplateUrl,
comment = this.$compile('<!-- hidden mct element -->')(scope), comment = this.$compile('<!-- hidden mct element -->')(scope),
activeScope,
self = this; self = this;
function destroyScope() {
if (activeScope) {
activeScope.$destroy();
activeScope = undefined;
}
}
function removeElement() { function removeElement() {
if (activeElement !== comment) { if (activeElement !== comment) {
destroyScope();
activeElement.replaceWith(comment); activeElement.replaceWith(comment);
activeElement = comment; activeElement = comment;
} }
@ -110,8 +119,10 @@ define(
} }
function populateElement(template) { function populateElement(template) {
destroyScope();
activeScope = scope.$new(false);
element.empty(); element.empty();
element.append(self.$compile(template)(scope)); element.append(self.$compile(template)(activeScope));
} }
function badTemplate(templateUrl) { function badTemplate(templateUrl) {