How to bind Mixed Json to Table in angularjs -


{ "_id" : 1, "name" : { "first" : "john", "last" : "backus" }, "contribs" : [ "fortran", "algol", "backus-naur form", "fp" ], "awards" : [            {              "award" : "w.w. mcdowell award",              "year" : 1967,              "by" : "ieee computer society"            },            { "award" : "draper prize",              "year" : 1993,              "by" : "national academy of engineering"            } ] } 

i have take json format , binded in table using ng-repeat.

ng repaet sample in html file:

<body ng-controller="ctrl"> 

<tbody ng-repeat="dat in alldata">    <tr>     <td colspan="3">{{dat.name.first}} {{dat.name.last}}</td>    </tr>     <tr><td colspan="3" align="center"><span style="font-weight:bold">contribution</span></td></tr>    <tr ng-repeat="cont in dat.contribs">     <td colspan="3">{{ cont}}</td>    </tr>     <tr><td colspan="3" align="center"><span style="font-weight:bold">awards</span></td></tr>     <tr ng-repeat="aw in dat.awards">     <td>{{ aw.award}}</td>         <td>{{ aw.year}}</td>         <td>{{ aw.by}}</td>    </tr>   </tbody> 

sample script file:

var app = angular.module("app",[]);  app.controller('ctrl', function($scope) {   $scope.alldata = [    {      "_id":1,    "name":{         "first":"john",       "last":"backus"    },    "contribs":[         "fortran",       "algol",       "backus-naur form",       "fp"    ],    "awards":[         {            "award":"w.w. mcdowell award",          "year":1967,          "by":"ieee computer society"       },       {            "award":"draper prize",          "year":1993,          "by":"national academy of engineering"       }    ] }   ]; }); 

please find plnkr link it: plnkr


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -