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

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현