I'm trying to build an editable table cell however there are some conditions that determine whether it is editable or not so I can't just include an input in the template. My goal is to have the cell create an input using the same model that the cell has but it doesn't seem to work.
HTML:
<td editable-grid-cell ng-model="batch.amount" name="amount"></td>
Directive Code:
.directive('editableGridCell', function($compile) {
return {
link: function(scope, ele, attrs) {
scope.field = attrs.ngModel;
ele.append($compile('<input type="text" class="form-control" ng-model="field"/>')(scope));
}
}
})
Doing this results in the input being populated with 'batch.amount'. I've gotten this to work by using an isolated scope:
scope: {
model: '=ngModel'
}
...
ele.append($compile('<input type="text" class="form-control" ng-model="model"/>')(scope));
However, I need access to the parent scope because I have all my table options set in the controller so I think isolated scope won't work here.
Thanks for the help!