Javascript 角度js中的动态数据表
我想在angular js中创建一个动态数据表,它的第一列带有复选框。数据将采用Json格式,如下所示Javascript 角度js中的动态数据表,javascript,jquery,html,angularjs,Javascript,Jquery,Html,Angularjs,我想在angular js中创建一个动态数据表,它的第一列带有复选框。数据将采用Json格式,如下所示 $scope.items = [ { "id": "1", "lastName": "Test1", "firstName": "Test", "email": "test1@example.com" }, { "id": "2", "lastName": "Test2", "firstName": "Test", "email": "test2@example
$scope.items = [
{ "id": "1", "lastName": "Test1", "firstName": "Test", "email": "test1@example.com" },
{ "id": "2", "lastName": "Test2", "firstName": "Test", "email": "test2@example.com" },
{ "id": "3", "lastName": "Test3", "firstName": "Test", "email": "test3@example.com" },
{ "id": "4", "lastName": "Test4", "firstName": "Test", "email": "test4@example.com" },
{ "id": "5", "lastName": "Test5", "firstName": "Test", "email": "test5@example.com" }
];
id将是一个带有复选框的列,所有其他列都将包含数据。
表的标题也是动态的,列也是动态的。如果列是动态的
<table style="width:100%">
<tr ng-repeat="item in items | limitTo:1">
<th ng-repeat="(key,value) in item">{{key}}</th>
<td ng-repeat="(key,value) in item">
<div ng-show="key == 'id'">
<input type="checkbox" value={{value}} name="id" />
</div>
<div ng-show="key != 'id'">
{{value}}
</div>
</td>
</tr>
</table>
{{key}}
{{value}}
ng repeat对键进行JSON排序,首先获取ID,然后跳过JSON排序(因为您的JSON在跳过JSON排序后首先具有ID,您将首先获取ID)如何在angularjs中创建一个动态表,并使用上面的JSON将第一列作为复选框?这些列是动态的,因此我无法写入,{item.lastName}这是一个非常有用的答案。