ngCell element disconnected from DOM during $compile causes inheritedData() problems
I found this issue trying to use the built in $pristine, $invalid and $dirty handling in angular's ngForm and ngModel. If you customize the cellTemplate to be an editor using ngModel the $dirty, $invalid, etc states are never updated in the form.
The issue is caused because the ngCell directive compiles the cell template before it's attached to the DOM. This means that anything that template does that depends on angular's inheritedData() will be broken.
Here's a plunk illustrating the issue. http://plnkr.co/edit/Mt2wccRpmn6aEemSqfTf
I've also included in the plunk a patched ng-grid.js that has the fix I've been using, you can swap that in to see how it should behave.
Essentially, I changed the order of this:
var cellElement = $compile(html)($scope);
if ($scope.enableCellSelection && cellElement[0].className.indexOf('ngSelectionCell') === -1) {
cellElement[0].setAttribute('tabindex', 0);
cellElement.addClass('ngCellElement');
}
iElement.append(cellElement);
To:
var cellElement = $(html);
iElement.append(cellElement);
$compile(cellElement)($scope);
if ($scope.enableCellSelection && cellElement[0].className.indexOf('ngSelectionCell') === -1) {
cellElement[0].setAttribute('tabindex', 0);
cellElement.addClass('ngCellElement');
}
Closed via #1010