I have a spreadsheet-like table setup built with table elements that have use angular to enable editing, including a row select/delete function. This is the html that enables a row to be highlighted if its "selected":
<tr row-id="0" ng-class="selectedClass(5)" class="ng-scope budget-row">
<td>
<label id="foo" ng-hide="some_function(5)">{{row(5).value}}</label>
<input type="text" ng-hide="!some_function(5)">
</td>
<td>...</td>
</tr>
The ng-class="selectedClass(5)" is used to apply a background color to the row when selected.
Once a row is selected, it can be "cut". The cut method is called on the scope, and it removes the underlying row object and removes the element from the Dom as follows:
let el = angular.element("#foo");
let deleteTarget = el.parent().parent();
deleteTarget.remove();
This all works fine on the page, but I can see on the console and the stack trace, that ng-class directive is still apparently firing on the removed rows even after they are removed from the page. Although it works fine now, I can see it becoming very slow if all the rows that are deleted are still being checked for changes by angular even if they are no longer present on the page.
Here's the stack trace where the "isSelected" function is being called from a element that has already been removed.
isSelected (budget_items.self-e32480dfbdba1522e84f3891a1bef58643f758332acf63bc6a7e4b06bfee6b49.js?body=1:688)
$scope.selectedClass (budget_items.self-e32480dfbdba1522e84f3891a1bef58643f758332acf63bc6a7e4b06bfee6b49.js?body=1:50)
fn (VM700:4)
expressionInputWatch (angular.self-78d77e4a3c91d5788f4be38711bc43955307738d52116f065bc1289f6abc3523.js?body=1:16661)
$digest (angular.self-78d77e4a3c91d5788f4be38711bc43955307738d52116f065bc1289f6abc3523.js?body=1:18364)
$apply (angular.self-78d77e4a3c91d5788f4be38711bc43955307738d52116f065bc1289f6abc3523.js?body=1:18641)
(anonymous) (angular.self-78d77e4a3c91d5788f4be38711bc43955307738d52116f065bc1289f6abc3523.js?body=1:27469)
dispatch (jquery3.self-5af507e253c37e9c9dcf65064fc3f93795e6e28012780579975a4d709f4074ad.js?body=1:5184)
elemData.handle (jquery3.self-5af507e253c37e9c9dcf65064fc3f93795e6e28012780579975a4d709f4074ad.js?body=1:4992)