我有一个JSON,我想将其放入Web应用程序的前端,以拆分成多个表(准确地说是4个表)。
现在,我将JSON列表中的所有数据显示在一个表中。
我正在使用AngularJS。有没有一种方法可以将数据拆分为多个表,而无需更改SQL Server中的数据库(拆分为4)。
答案 0 :(得分:0)
这里是一个例子:
angular.module('myApp', []).controller('personCtrl', function($scope) {
$scope.test = [
{name:'audi1',price:'200'},
{name:'audi2',price:'200'},
{name:'audi3',price:'200'},
{name:'audi4',price:'200'},
{name:'audi5',price:'200'},
{name:'audi6',price:'200'},
{name:'audi7',price:'200'}
];
});
<div class="row">
<div class="col-md-6" ng-repeat="group in [0,1] ">
<p>{{group}}</p>
<p ng-repeat="t in test" ng-if="group == test.indexOf(t) >= test.length/2" >
{{t}}
</p>
<br>
</div>
</div>
哪个会输出:
0
{"name":"audi1","price":"200"}
{"name":"audi2","price":"200"}
{"name":"audi3","price":"200"}
{"name":"audi4","price":"200"}
1
{"name":"audi5","price":"200"}
{"name":"audi6","price":"200"}
{"name":"audi7","price":"200"}