HTML
<table st-table="ApplicationData.displayedCollection" class="table table-striped" st-safe-src="ApplicationData.source">
<thead>
<tr ng-repeat="col in ApplicationData.columns">
<td st-sort="{{col.name}}">{{col.caption}}</td>
</tr>
</thead>
JS
$scope.ApplicationData = {
source: [],
displayedCollection: [],
columns: [{ name: 'APPLICATION_CODE', caption: 'Code', isSort: true },
{ name: 'APPLICATION_NAME', caption: 'Application', isSort: true }],
};
输出
<table st-table="ApplicationData.displayedCollection" class="table table-striped" st-safe-src="ApplicationData.source">
<thead>
<tr ng-repeat="col in ApplicationData.columns" class="ng-scope">
<td class="ng-binding">Code</td></tr>
<tr ng-repeat="col in ApplicationData.columns" class="ng-scope">
<td class="ng-binding">Application</td></tr>
</thead>
</table>
嗨,我正在使用这个html动态生成列,但是每次尝试我都会获得动态生成的行。请查看我附上的代码并告诉我这个问题。
答案 0 :(得分:1)
只需稍微修改模板:将ng-repeat从<tr>
移到<td>
中
改变这个:
<thead>
<tr ng-repeat="col in ApplicationData.columns">
<td st-sort="{{col.name}}">{{col.caption}}</td>
</tr>
</thead>
例如,:
<thead>
<tr>
<td ng-repeat="col in ApplicationData.columns">{{col.caption}}</td>
</tr>
</thead>
这里有一个代码:https://jsfiddle.net/86y3yxmk/1/
另外,对于您可能要完成的任务,这是一个很好的解读:https://www.codementor.io/debugging/4948713248/request-want-to-use-values-in-nested-ng-repeat
GL!