smart-table ng-repeat 无法正确呈现动态列

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!