List Item focus
by ed4becky
HTML
<div ng-app='myApp'>
<div ng-controller="ctrl">
<table>
<thead>
<tr>
<th>Claim</th>
<th>Class</th>
<th>Subject</th>
</tr>
</thead>
<tbody>
<tr class='claimrow' data-ng-repeat='c in elements'>
<td>
<div contenteditable=true>{{c.claim}}</div>
</td>
<td>{{c.class}}</td>
<td>{{c.subject}}</td>
</tr>
</tbody>
</table>
<button ng-click='clicked()'>Add Row</button>
</div>
</div>
CSS
div {
margin-left: 1em;
}
table, th, td {
border: 1px solid black;
width: 50%;
padding: 5px;
}
JavaScript
var myApp = angular.module('myApp', []);
myApp.controller('ctrl', ['$scope', '$timeout', Ctrl]);
function Ctrl($scope, $timeout) {
$scope.elements = [{
'claim': 'foo',
class: 'class1',
subject: 'name1'
}, {
'claim': 'bar',
class: 'class1',
subject: 'name2'
}, {
'claim': 'baz',
class: 'class1',
subject: 'name2'
}, {
'claim': 'quux',
class: 'class1',
subject: 'name3'
}];
$scope.clicked = function() {
$scope.elements.push({});
}
}