Nik*_*ppa 12 angularjs smart-table
我正在使用棱角分距v1.3.15.我通过点击api并将其通过范围传递到智能表来获取数据

以下是控制台上显示的'scope.rowCollection'的数据格式

数据填充正常,但是当我尝试单击表标题并使用st-sort方法对其进行排序时,表值显然为空,而不是对列进行排序.这是我的html片段的视图

你能告诉我我做错了什么吗?我使用自己的数据收集集(非硬编码)的那一刻,整个表格值变得混乱.我感觉它与我在角度端使用的变量名称有关.非常感谢任何帮助....谢谢
Lui*_*spo 29
点击您的评论Nikhil.像这样使用st-safe-src:
HTML
<table st-table="displayedCollection" st-safe-src="rowCollection">
<thead>
<tr>
<th st-sort="firstName">First Name</th>
<th st-sort="lastName">Last Name</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in displayedCollection">
<td>{{row.firstName}}</td>
<td>{{row.lastName}}</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
JS
app.controller('Ctrl', function($scope, service) {
$scope.displayedCollection = [];
service.all.then(function(list) {
$scope.rowCollection = list;
$scope.displayedCollection = list;
});
});
Run Code Online (Sandbox Code Playgroud)
而已.
小智 5
如果要异步导入数据(从远程数据库,静态端点,ajax调用等),则必须使用stSafeSrc属性。您必须对基础集合和安全集合使用单独的集合,否则可能会陷入无限循环。
由于我从宁静的服务中获取数据,因此st-table =“ displayedCollection” st-safe-src =“ rowCollection”解决了我的问题
| 归档时间: |
|
| 查看次数: |
19322 次 |
| 最近记录: |