SO 23430830 - arrow navigation question
Fiddle for Stack Overflow Question. http://stackoverflow.com/questions/23430830/keyboard-navigation-in-angularjs-table
by HoffZ
HTML
<div ng-app>
<div ng-controller="TestingCtrl">
<table>
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="p in persons">
<td>
<input ng-model="p.name">
</td>
<td>
<input ng-model="p.age">
</td>
<td>
<button ng-click="add($index)">Add new person</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
JavaScript
function TestingCtrl($scope) {
$scope.persons = [{
name: 'Alice',
age: 20
}, {
name: 'Bob',
age: 30
}];
$scope.add = function (index) {
var newPerson = function () {
return {
name: '',
age: ''
};
};
$scope.persons.splice(index + 1, 0, new newPerson());
}
}