Skip to content

Commit

Permalink
properly destroy compiled angular scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Mar 15, 2017
1 parent b8ac4ae commit 4cc41ca
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion public/tooltip/visTooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ define(function (require) {
}

destroy() {
this.$tooltipScope.$destroy();
if (this.$visEl) {
this.$visEl.remove();
}
this.$tooltipScope.$destroy();
}

getFormatter() {
Expand Down
26 changes: 17 additions & 9 deletions public/vislib/marker_types/base_marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ define(function (require) {
// on relevant map events, and returns the element containing the control
let $div = $('<div>').addClass('tilemap-legend');

const $sliderScope = $rootScope.$new();
$sliderScope.slider = {
self.$sliderScope = $rootScope.$new();
self.$sliderScope.slider = {
min: self.threshold.min,
max: self.threshold.max,
options: {
Expand All @@ -81,7 +81,7 @@ define(function (require) {
}
};
const linkFn = $compile(require('./legendSlider.html'));
const $sliderEl = linkFn($sliderScope);
const $sliderEl = linkFn(self.$sliderScope);
$div.append($sliderEl);

_.each(self._legendColors, function (color, i) {
Expand All @@ -107,6 +107,19 @@ define(function (require) {
self._legend.addTo(self.map);
};

BaseMarker.prototype.removeLegend = function () {
if (this.$sliderScope) {
this.$sliderScope.$destroy();
}

if (this._legend) {
if (this._legend._map) {
this.map.removeControl(this._legend);
}
this._legend = undefined;
}
}

/**
* Apply style with shading to feature
*
Expand Down Expand Up @@ -199,12 +212,7 @@ define(function (require) {
});
this._hidePopup();

if (this._legend) {
if (this._legend._map) {
this.map.removeControl(this._legend);
}
this._legend = undefined;
}
this.removeLegend();

// remove marker layer from map
if (this._markerGroup) {
Expand Down

0 comments on commit 4cc41ca

Please sign in to comment.