I took the initiative to fork and enhance your Plunker by creating a custom directive for a table. It's essential to use semantic markup when working with tables, so I made some modifications to your HTML code.
Furthermore, I made improvements to your select-me
directive to demonstrate how auto-selection on click and arrow key navigation can be implemented.
Check out the updated Plunker here!
layout.html
<table>
<thead>
<tr ng-repeat="element in header" class="header-cells" style="width:{{element.width}}px">
<th>{{element.column}}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="element in body" data-indexrow="{{$index}}">
<td ng-repeat="h in header" class="custom-row" data-indexcol="{{$index}}">
<input type="text" ng-model="element[h.column]" class="body-cell" style="width:{{h.width}}px" select-me>
</td>
</tr>
</tbody>
</table>
selectMe directive (JS)
ct.directive("selectMe", function() {
return ({
restrict: "A",
link: link
});
function link(scope, element, attributes) {
element.on('click', function(e) {
element.select();
});
element.on('keyup', function(e) {
var $input = angular.element(this),
$td = $input.parent(),
$tr = $td.parent(),
indexrow = parseInt($tr.attr('data-indexrow'),10),
indexcol = parseInt($td.attr('data-indexcol'),10);
console.log(indexrow);
console.log(indexcol);
// Additional functionality for arrow key navigation can be added here
});
}
});