Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

Commit cd7754a

Browse files
Fix problem when data refreshed the "Angular way"
Child scopes from the rows that are no longer present were not being destroyed.
1 parent 113323c commit cd7754a

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

dist/angular-datatables.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,7 @@ function dtNGRenderer($log, $q, $compile, $timeout, DTRenderer, DTRendererServic
897897
var _oTable;
898898
var _$elem;
899899
var _parentScope;
900+
var _newParentScope;
900901
var dtInstance;
901902
var renderer = Object.create(DTRenderer);
902903
renderer.name = 'DTNGRenderer';
@@ -959,10 +960,14 @@ function dtNGRenderer($log, $q, $compile, $timeout, DTRenderer, DTRendererServic
959960
}
960961

961962
function _destroyAndCompile() {
963+
if (_newParentScope) {
964+
_newParentScope.$destroy();
965+
}
962966
_oTable.ngDestroy();
963967
// Re-compile because we lost the angular binding to the existing data
964968
_$elem.html(_staticHTML);
965-
$compile(_$elem.contents())(_parentScope);
969+
_newParentScope = _parentScope.$new();
970+
$compile(_$elem.contents())(_newParentScope);
966971
}
967972
}
968973
}

0 commit comments

Comments
 (0)