From 031a8dabcc90a366abb4c7aceca46fce2addb987 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Sun, 3 Sep 2017 15:49:42 +0800 Subject: [PATCH] fix chart would not be destoried when that is unused --- src/scripts/directives/chart.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/scripts/directives/chart.js b/src/scripts/directives/chart.js index daebc71..8f4f29a 100644 --- a/src/scripts/directives/chart.js +++ b/src/scripts/directives/chart.js @@ -38,6 +38,12 @@ setOptions(value); } }, true); + + scope.$on('$destroy', function() { + if (chart && !chart.isDisposed()) { + chart.dispose(); + } + }); } }; }]).directive('ngPopChart', ['$window', 'chartTheme', function ($window, chartTheme) { @@ -79,7 +85,7 @@ chart = echarts.init(wrapper[0], chartTheme.get(options.ngTheme)); }).on('hide.bs.popover', function () { - if (chart && chart.isDisposed()) { + if (chart && !chart.isDisposed()) { chart.dispose(); } }).on('hidden.bs.popover', function () {