How can you nest curly-braced model delimiters in AngularJS? -
i have app user can select database table name dropdown, app makes http call out database, retrieves table column names data columns, , returns data script. far, good. code set handle fact not know table - column names, nor how many columns table has. dump data object called tabledata, tabledata.columns contains of column names , tabledata.results contains data contained in rows columns in database. object may this:
{ "columns": [{ "name": "lo_code"}, { "name": "lo_desc"}, { "name": "lo_inactive"}], "results": [{ "lo_code": "7" , "lo_desc": "staff area 7" , "lo_inactive": "0"}, { "lo_code": "12", "lo_desc": "staff area 12", "lo_inactive": "0"}, { "lo_code": "15", "lo_desc": "staff area 15", "lo_inactive": "1"}, { "lo_code": "m" , "lo_desc": "miscellaneous", "lo_inactive": "0"}]}
what want create table columns in header row , of remaining data in rows below. have following create table:
<table> <tbody> <tr> <th ng-repeat="column in tabledata.columns">{{column.name}}</th> </tr> <tr ng-repeat="result in tabledata.results"> <td ng-repeat="column in tabledata.columns"> ??????? </td> </tr> </tbody> </table>
i'm not sure how reference object data in td. tried
<td ng-repeat="column in tabledata.columns">{{result.{{column.name}}}}</td>
but gives me unexpected token error. i'm guessing nesting of angular model delimiters isn't way go this.
here fiddle sample object data. so, can put in place of ??????? data want?
<td ng-repeat="column in tabledata.columns">{{ result[column.name] }}</td>
Comments
Post a Comment