我正在尝试动态填充表中的列:http: //jsfiddle.net/REjUv/1/
$scope 有一个列定义数组,每个都有一个属性名称和一个行的项目数组
我正在尝试将 td 元素的内容设置为具有相关列中名称的项目的属性
<div ng-app ng-controller='ListController'>
<table>
<tr>
<th ng-repeat='column in columns'>{{column.text}}</th>
</tr>
<tr ng-repeat='item in items'>
<td ng-repeat='column in columns'>
<!--how do i set the ng-bind to item.[column.name]-->
<label type='text' ng-bind='item.name' />
</td>
</tr>
</table>
</div>
function ListController($scope){
$scope.columns = [
{ name: 'id', text: 'Id' },
{ name: 'code', text: 'Code' },
{ name: 'name', text: 'Name' }
];
$scope.items = [
{ id:1, code: 'A', name: 'AAA' },
{ id:2, code: 'B', name: 'BBB' },
{ id:3, code: 'C', name: 'CCC' },
{ id:4, code: 'D', name: 'DDD' }
];
}