angularjs - ng-repeat is not working for the json value -
angularjs - ng-repeat is not working for the json value -
i have code this:
<tr ng-repeat="tagjson in taglist"> <div ng-repeat="(key, value) in tagjson"> <td width="48%" ng-class-odd="'evn'" ng-class-even="'odd'"> {{key}} </td> <td width="48%" ng-class-odd="'evn'" ng-class-even="'odd'"> {{value}} </td> </div> </tr>
where taglist
:
[{a:1},{a:1}]
but key
, value
empty! not sure why thats case. if seek print tagjson
in html like:
{{tagjson}}
it print:
{a:1} {a:1}
but key
, value
doesnt work!
where i'm making mistakes?
see here:
http://jsfiddle.net/vwsej/126/
the actual reason why don't see is, akonsu posted, because you're producing invalid html.
to maintain values in seperate table cells, can utilize ng-repeat-start/end
, e.g.:
class="snippet-code-js lang-js prettyprint-override">var mainctrl = function () { this.taglist = [{a:1}, {b:2}]; }; angular .module('app', []) .controller('main', mainctrl) ;
class="snippet-code-css lang-css prettyprint-override">table { border-collapse: collapse; } td { border: 1px solid #ccc; padding: 5px; }
class="snippet-code-html lang-html prettyprint-override"><script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-rc.5/angular.min.js"></script> <div data-ng-app="app" data-ng-controller="main main"> <table> <tr ng-repeat="tagjson in main.taglist"> <td ng-repeat-start="(key, value) in tagjson" width="48%" ng-class-odd="'evn'" ng-class-even="'odd'"> {{key}} </td> <td ng-repeat-end width="48%" ng-class-odd="'evn'" ng-class-even="'odd'"> {{value}} </td> </tr> </table> </div>
angularjs
Comments
Post a Comment