[英]smart-table ng-repeat not rendering dynamic columns properly
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动态生成列,但是每当我尝试获取动态生成的行时,我就会每次使用。 请查看随附的代码,让我知道该问题。
只需稍微编辑模板即可:将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>
这是一个使用以下代码的jsfiddle: https ://jsfiddle.net/86y3yxmk/1/
此外,这是您可能想要完成的工作的不错的阅读: https : //www.codementor.io/debugging/4948713248/request-want-to-use-values-in-nested-ng-repeat
GL!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.