-3

I have a JSON that I would like to put in the front end of my web application to be split into multiple tables (4 in precise).

Right now I have all my data from the JSON list is displayed in one table.

I am using AngularJS. Is there a way to split data into multiple tables without making changes to the database in the SQL Server (splitting by 4).

5
  • There's not much details to work with here. Is there a criteria you want to split the data by? You can just split the data on the front end by that criteria and give that data to 4 different tables. Commented Jul 12, 2018 at 12:16
  • I don't have a criteria I just want to dynamically split data into four different tables. Commented Jul 12, 2018 at 12:23
  • What does "dynamically" mean in your context? Split it into 4 equal parts? Split it into 4 random tables? Commented Jul 12, 2018 at 12:24
  • Split into 4 equal parts. Commented Jul 12, 2018 at 12:26
  • Just divide array into four parts Commented Jul 12, 2018 at 12:37

1 Answer 1

0

Here is an example:

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>

Which will output:

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"}
Sign up to request clarification or add additional context in comments.

1 Comment

This worked perfectly. Thank you

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.