diff --git a/angular-selectize.js b/angular-selectize.js index 3b4947b..78c87b5 100644 --- a/angular-selectize.js +++ b/angular-selectize.js @@ -42,6 +42,7 @@ var selectize, newModelValue, newOptions, updateTimer; watchModel(); + subscribeToScopeDestroy(); if (attrs.ngDisabled) { watchParentNgDisabled(); @@ -246,11 +247,14 @@ return displayFn(optionContext); } - scope.$on('$destroy', function() { - if (updateTimer) { - $timeout.cancel(updateTimer); - } - }); + function subscribeToScopeDestroy() { + scope.$on('$destroy', function () { + if (updateTimer) { + $timeout.cancel(updateTimer); + } + if (selectize) selectize.destroy(); + }); + } } }; }]);