How to display array with ng-repeatng-repeat Angular and JSON arrayAngularJS ng-repeat for object contains objects and arraysInsert HTML into view from AngularJS controllerHow does data binding work in AngularJS?How to use ng-repeat for dictionaries in AngularJs?ng-repeat finish eventng-repeat :filter by single fieldHow to iterate over the keys and values with ng-repeat in AngularJS?angular ng-repeat in reverseHow to display length of filtered ng-repeat dataWay to ng-repeat defined number of times instead of repeating over array?Adding parameter to ng-click function inside ng-repeat doesn't seem to work

What's the 2-minute timer on mobile Deutsche Bahn tickets?

Which "exotic salt" can lower water's freezing point by –70 °C?

A 2-connected graph contains a path passing through all the odd degree vertices

How do I download programs on Linux?

Can an earth elemental drag a tiny creature underground with Earth Glide?

Primes in a Diamond

As a GM, is it bad form to ask for a moment to think when improvising?

What does the phrase "go for the pin" mean here?

Debian 9 server no sshd in auth.log

How do I, as a DM, handle a party that decides to set up an ambush in a dungeon?

Problem with estimating a sequence with intuition

Why can't argument be forwarded inside lambda without mutable?

What is monoid homomorphism exactly?

Can I combine SELECT TOP() with the IN operator?

Which version of the Squat Nimbleness feat is correct?

Dimmer switch not connected to ground

Given a safe domain, are subdirectories safe as well?

What would happen if I combined this polymer and this metal (assuming I can)

Is crescere the correct word meaning to to grow or cultivate?

What detail can Hubble see on Mars?

Emergency stop in plain TeX, pdfTeX, XeTeX and LuaTeX?

How is trade in services conducted under the WTO in the absence of the Doha conclusion?

My large rocket is still flipping over

How to deal with employer who keeps me at work after working hours



How to display array with ng-repeat


ng-repeat Angular and JSON arrayAngularJS ng-repeat for object contains objects and arraysInsert HTML into view from AngularJS controllerHow does data binding work in AngularJS?How to use ng-repeat for dictionaries in AngularJs?ng-repeat finish eventng-repeat :filter by single fieldHow to iterate over the keys and values with ng-repeat in AngularJS?angular ng-repeat in reverseHow to display length of filtered ng-repeat dataWay to ng-repeat defined number of times instead of repeating over array?Adding parameter to ng-click function inside ng-repeat doesn't seem to work






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have an json array of the form":



 
"School1": ["name": "john", "age":"28",
"name": "paul", "age":"27"],
"School2": ["name": "david", "age":"27",
"name": "sil", "age":"28"]



How do I display in the table in this form using ng-repeat in Angular:




----------
Name | Age
----------
School1
----------
john | 28
----------
paul | 2
----------
School2
----------
david| 27
----------
sil| 28
----------





I will Apreciate help with this.










share|improve this question



















  • 1





    Do some research, documenting what research was done, what was found, and, if it didn’t solve the problem, why. Create a small prototype that isolates the issue. Make at least one attempt at implementing a solution.

    – georgeawg
    Mar 22 at 23:21











  • See How do I ask and answer homework questions?.

    – georgeawg
    Mar 22 at 23:23











  • Possible duplicate of ng-repeat Angular and JSON array

    – William Humphreys
    Mar 22 at 23:49

















0















I have an json array of the form":



 
"School1": ["name": "john", "age":"28",
"name": "paul", "age":"27"],
"School2": ["name": "david", "age":"27",
"name": "sil", "age":"28"]



How do I display in the table in this form using ng-repeat in Angular:




----------
Name | Age
----------
School1
----------
john | 28
----------
paul | 2
----------
School2
----------
david| 27
----------
sil| 28
----------





I will Apreciate help with this.










share|improve this question



















  • 1





    Do some research, documenting what research was done, what was found, and, if it didn’t solve the problem, why. Create a small prototype that isolates the issue. Make at least one attempt at implementing a solution.

    – georgeawg
    Mar 22 at 23:21











  • See How do I ask and answer homework questions?.

    – georgeawg
    Mar 22 at 23:23











  • Possible duplicate of ng-repeat Angular and JSON array

    – William Humphreys
    Mar 22 at 23:49













0












0








0








I have an json array of the form":



 
"School1": ["name": "john", "age":"28",
"name": "paul", "age":"27"],
"School2": ["name": "david", "age":"27",
"name": "sil", "age":"28"]



How do I display in the table in this form using ng-repeat in Angular:




----------
Name | Age
----------
School1
----------
john | 28
----------
paul | 2
----------
School2
----------
david| 27
----------
sil| 28
----------





I will Apreciate help with this.










share|improve this question
















I have an json array of the form":



 
"School1": ["name": "john", "age":"28",
"name": "paul", "age":"27"],
"School2": ["name": "david", "age":"27",
"name": "sil", "age":"28"]



How do I display in the table in this form using ng-repeat in Angular:




----------
Name | Age
----------
School1
----------
john | 28
----------
paul | 2
----------
School2
----------
david| 27
----------
sil| 28
----------





I will Apreciate help with this.







angularjs html-table angularjs-ng-repeat






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 23 at 4:05









georgeawg

35.7k115470




35.7k115470










asked Mar 22 at 23:13









KenadetKenadet

16729




16729







  • 1





    Do some research, documenting what research was done, what was found, and, if it didn’t solve the problem, why. Create a small prototype that isolates the issue. Make at least one attempt at implementing a solution.

    – georgeawg
    Mar 22 at 23:21











  • See How do I ask and answer homework questions?.

    – georgeawg
    Mar 22 at 23:23











  • Possible duplicate of ng-repeat Angular and JSON array

    – William Humphreys
    Mar 22 at 23:49












  • 1





    Do some research, documenting what research was done, what was found, and, if it didn’t solve the problem, why. Create a small prototype that isolates the issue. Make at least one attempt at implementing a solution.

    – georgeawg
    Mar 22 at 23:21











  • See How do I ask and answer homework questions?.

    – georgeawg
    Mar 22 at 23:23











  • Possible duplicate of ng-repeat Angular and JSON array

    – William Humphreys
    Mar 22 at 23:49







1




1





Do some research, documenting what research was done, what was found, and, if it didn’t solve the problem, why. Create a small prototype that isolates the issue. Make at least one attempt at implementing a solution.

– georgeawg
Mar 22 at 23:21





Do some research, documenting what research was done, what was found, and, if it didn’t solve the problem, why. Create a small prototype that isolates the issue. Make at least one attempt at implementing a solution.

– georgeawg
Mar 22 at 23:21













See How do I ask and answer homework questions?.

– georgeawg
Mar 22 at 23:23





See How do I ask and answer homework questions?.

– georgeawg
Mar 22 at 23:23













Possible duplicate of ng-repeat Angular and JSON array

– William Humphreys
Mar 22 at 23:49





Possible duplicate of ng-repeat Angular and JSON array

– William Humphreys
Mar 22 at 23:49












1 Answer
1






active

oldest

votes


















0














You can perform some operation on your data and can create another object with the modified structure so that it can be used with ng-repeat to display the table in the form you want.



You can understand this better with an example.



This is your data that you want to display in table view



 $scope.testData = 
"School1": ["name": "john", "age":"28",
"name": "paul", "age":"27"],
"School2": ["name": "david", "age":"27",
"name": "sil", "age":"28"]



We perform an operation on "testData" to identify the keys in this JSON Object which are "School1" and "School2".Following line performs that operation.



$scope.keys = Object.keys($scope.testData);


$scope.keys will be an array of keys : ["School1",School2"];



Then you can iterate on the array of keys and create another object that can be used with ng-repeat in HTML code.
Following lines perform create that object(tableData):



$scope.tableData=[];
//Iterating on array of keys
$scope.keys.forEach(element =>
$scope.tableData.push(
column : element,
data : $scope.testData[element] //Getting your data from testData
);
);


Final Code Snippet that will go in the controller will be :



 $scope.testData = 
"School1": ["name": "john", "age":"28",
"name": "paul", "age":"27"],
"School2": ["name": "david", "age":"27",
"name": "sil", "age":"28"]


$scope.keys = Object.keys($scope.testData);

$scope.tableData=[];
$scope.keys.forEach(element =>
$scope.tableData.push(
column : element,
data : $scope.testData[element]
);
);


And your HTML Code will go something like this:



<table>
<tr>
<th>Name |</th>
<th>Age</th>
</tr>
</table>
<table ng-repeat="table in tableData">
<tr>
<th>table.column</th>
</tr>
<tr ng-repeat="row in table.data">
<td>row.name | </td>
<td>row.age</td>
</tr>
</table>


You can definitely beautify the table view by writing your own css or by including any predefined stylesheets.
Hope that helps!!






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55308942%2fhow-to-display-array-with-ng-repeat%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You can perform some operation on your data and can create another object with the modified structure so that it can be used with ng-repeat to display the table in the form you want.



    You can understand this better with an example.



    This is your data that you want to display in table view



     $scope.testData = 
    "School1": ["name": "john", "age":"28",
    "name": "paul", "age":"27"],
    "School2": ["name": "david", "age":"27",
    "name": "sil", "age":"28"]



    We perform an operation on "testData" to identify the keys in this JSON Object which are "School1" and "School2".Following line performs that operation.



    $scope.keys = Object.keys($scope.testData);


    $scope.keys will be an array of keys : ["School1",School2"];



    Then you can iterate on the array of keys and create another object that can be used with ng-repeat in HTML code.
    Following lines perform create that object(tableData):



    $scope.tableData=[];
    //Iterating on array of keys
    $scope.keys.forEach(element =>
    $scope.tableData.push(
    column : element,
    data : $scope.testData[element] //Getting your data from testData
    );
    );


    Final Code Snippet that will go in the controller will be :



     $scope.testData = 
    "School1": ["name": "john", "age":"28",
    "name": "paul", "age":"27"],
    "School2": ["name": "david", "age":"27",
    "name": "sil", "age":"28"]


    $scope.keys = Object.keys($scope.testData);

    $scope.tableData=[];
    $scope.keys.forEach(element =>
    $scope.tableData.push(
    column : element,
    data : $scope.testData[element]
    );
    );


    And your HTML Code will go something like this:



    <table>
    <tr>
    <th>Name |</th>
    <th>Age</th>
    </tr>
    </table>
    <table ng-repeat="table in tableData">
    <tr>
    <th>table.column</th>
    </tr>
    <tr ng-repeat="row in table.data">
    <td>row.name | </td>
    <td>row.age</td>
    </tr>
    </table>


    You can definitely beautify the table view by writing your own css or by including any predefined stylesheets.
    Hope that helps!!






    share|improve this answer



























      0














      You can perform some operation on your data and can create another object with the modified structure so that it can be used with ng-repeat to display the table in the form you want.



      You can understand this better with an example.



      This is your data that you want to display in table view



       $scope.testData = 
      "School1": ["name": "john", "age":"28",
      "name": "paul", "age":"27"],
      "School2": ["name": "david", "age":"27",
      "name": "sil", "age":"28"]



      We perform an operation on "testData" to identify the keys in this JSON Object which are "School1" and "School2".Following line performs that operation.



      $scope.keys = Object.keys($scope.testData);


      $scope.keys will be an array of keys : ["School1",School2"];



      Then you can iterate on the array of keys and create another object that can be used with ng-repeat in HTML code.
      Following lines perform create that object(tableData):



      $scope.tableData=[];
      //Iterating on array of keys
      $scope.keys.forEach(element =>
      $scope.tableData.push(
      column : element,
      data : $scope.testData[element] //Getting your data from testData
      );
      );


      Final Code Snippet that will go in the controller will be :



       $scope.testData = 
      "School1": ["name": "john", "age":"28",
      "name": "paul", "age":"27"],
      "School2": ["name": "david", "age":"27",
      "name": "sil", "age":"28"]


      $scope.keys = Object.keys($scope.testData);

      $scope.tableData=[];
      $scope.keys.forEach(element =>
      $scope.tableData.push(
      column : element,
      data : $scope.testData[element]
      );
      );


      And your HTML Code will go something like this:



      <table>
      <tr>
      <th>Name |</th>
      <th>Age</th>
      </tr>
      </table>
      <table ng-repeat="table in tableData">
      <tr>
      <th>table.column</th>
      </tr>
      <tr ng-repeat="row in table.data">
      <td>row.name | </td>
      <td>row.age</td>
      </tr>
      </table>


      You can definitely beautify the table view by writing your own css or by including any predefined stylesheets.
      Hope that helps!!






      share|improve this answer

























        0












        0








        0







        You can perform some operation on your data and can create another object with the modified structure so that it can be used with ng-repeat to display the table in the form you want.



        You can understand this better with an example.



        This is your data that you want to display in table view



         $scope.testData = 
        "School1": ["name": "john", "age":"28",
        "name": "paul", "age":"27"],
        "School2": ["name": "david", "age":"27",
        "name": "sil", "age":"28"]



        We perform an operation on "testData" to identify the keys in this JSON Object which are "School1" and "School2".Following line performs that operation.



        $scope.keys = Object.keys($scope.testData);


        $scope.keys will be an array of keys : ["School1",School2"];



        Then you can iterate on the array of keys and create another object that can be used with ng-repeat in HTML code.
        Following lines perform create that object(tableData):



        $scope.tableData=[];
        //Iterating on array of keys
        $scope.keys.forEach(element =>
        $scope.tableData.push(
        column : element,
        data : $scope.testData[element] //Getting your data from testData
        );
        );


        Final Code Snippet that will go in the controller will be :



         $scope.testData = 
        "School1": ["name": "john", "age":"28",
        "name": "paul", "age":"27"],
        "School2": ["name": "david", "age":"27",
        "name": "sil", "age":"28"]


        $scope.keys = Object.keys($scope.testData);

        $scope.tableData=[];
        $scope.keys.forEach(element =>
        $scope.tableData.push(
        column : element,
        data : $scope.testData[element]
        );
        );


        And your HTML Code will go something like this:



        <table>
        <tr>
        <th>Name |</th>
        <th>Age</th>
        </tr>
        </table>
        <table ng-repeat="table in tableData">
        <tr>
        <th>table.column</th>
        </tr>
        <tr ng-repeat="row in table.data">
        <td>row.name | </td>
        <td>row.age</td>
        </tr>
        </table>


        You can definitely beautify the table view by writing your own css or by including any predefined stylesheets.
        Hope that helps!!






        share|improve this answer













        You can perform some operation on your data and can create another object with the modified structure so that it can be used with ng-repeat to display the table in the form you want.



        You can understand this better with an example.



        This is your data that you want to display in table view



         $scope.testData = 
        "School1": ["name": "john", "age":"28",
        "name": "paul", "age":"27"],
        "School2": ["name": "david", "age":"27",
        "name": "sil", "age":"28"]



        We perform an operation on "testData" to identify the keys in this JSON Object which are "School1" and "School2".Following line performs that operation.



        $scope.keys = Object.keys($scope.testData);


        $scope.keys will be an array of keys : ["School1",School2"];



        Then you can iterate on the array of keys and create another object that can be used with ng-repeat in HTML code.
        Following lines perform create that object(tableData):



        $scope.tableData=[];
        //Iterating on array of keys
        $scope.keys.forEach(element =>
        $scope.tableData.push(
        column : element,
        data : $scope.testData[element] //Getting your data from testData
        );
        );


        Final Code Snippet that will go in the controller will be :



         $scope.testData = 
        "School1": ["name": "john", "age":"28",
        "name": "paul", "age":"27"],
        "School2": ["name": "david", "age":"27",
        "name": "sil", "age":"28"]


        $scope.keys = Object.keys($scope.testData);

        $scope.tableData=[];
        $scope.keys.forEach(element =>
        $scope.tableData.push(
        column : element,
        data : $scope.testData[element]
        );
        );


        And your HTML Code will go something like this:



        <table>
        <tr>
        <th>Name |</th>
        <th>Age</th>
        </tr>
        </table>
        <table ng-repeat="table in tableData">
        <tr>
        <th>table.column</th>
        </tr>
        <tr ng-repeat="row in table.data">
        <td>row.name | </td>
        <td>row.age</td>
        </tr>
        </table>


        You can definitely beautify the table view by writing your own css or by including any predefined stylesheets.
        Hope that helps!!







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 25 at 18:59









        Tejas RathiTejas Rathi

        436




        436





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid …


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55308942%2fhow-to-display-array-with-ng-repeat%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

            Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?