在我的第一个有角度的应用程序中,我有这样的数据:
tree_rows = [{"level":1,"branch":{"Name":"USA","Area":9826675,"Population":318212000,"TimeZone":"UTC -5 to -10","children":[{"Name":"California","Area":423970,"Population":38340000,"TimeZone":"Pacific Time","children":[{"Name":"San Francisco","Area":231,"Population":837442,"TimeZone":"PST"},{"Name":"Los Angeles","Area":503,"Population":3904657,"TimeZone":"PST"}]},{"Name":"Illinois","Area":57914,"Population":12882135,"TimeZone":"Central Time Zone","children":[{"Name":"Chicago","Area":234,"Population":2695598,"TimeZone":"CST"}]}],"level":1,"expanded":true,"uid":"0.5810681234579533","Options":[]},"label":"USA","tree_icon":"icon-file glyphicon glyphicon-file fa fa-file","visible":true},{"level":1,"branch":{"Name":"Texas","Area":268581,"Population":26448193,"TimeZone":"Mountain","level":1,"expanded":true,"uid":"0.8260199765209109","Options":[]},"label":"Texas","tree_icon":"icon-file glyphicon glyphicon-file fa fa-file","visible":true}]
colDefinitions = [{"field":"Area"},{"field":"Population"},{"field":"TimeZone"},{"field":"children"}]
我尝试通过table-grid-view查看它:
<tr ng-repeat=\"row in tree_rows | filter:{visible:true} track by row.branch.uid\"
ng-class=\"'level-' + {{ row.level }} + (row.branch.selected ? ' active':'')\" class=\"tree-grid-row\">
<td class=\"text-primary\"><a ng-click=\"user_clicks_branch(row.branch)\"><i ng-class=\"row.tree_icon\"
ng-click=\"row.branch.expanded = !row.branch.expanded\"
class=\"indented tree-icon\"></i>
</a><span class=\"indented tree-label\" ng-click=\"user_clicks_branch(row.branch)\">
{{row.branch[expandingProperty]}}</span>
</td>
<td ng-repeat=\"col in colDefinitions\">{{row.branch[col.field]}}</td> - this line!!!
</tr>
并且一切正常,只是我想要显示的不是所有数据:<td ng-repeat=\"col in colDefinitions\">{{row.branch[col.field]}}</td>
但是例如{{row.branch[Name]}} , {{row.branch[Population]}}
并且我没有看到任何数据。但为什么呢?
如何通过字段从我的数组中获取数据?
ps:我用这个:https://github.com/khan4019/tree-grid-directive/blob/master/README.md
答案 0 :(得分:1)
请尝试{{row.branch [&#34;姓名&#34;]}},引用字段名称