【发布时间】:2015-06-19 01:14:12
【问题描述】:
HTML 代码:
<table class="table table-bordered table-striped">
<thead>
<tr>
<td>one</td>
<td>two</td>
<td>three</td>
</tr>
</thead>
<tbody>
<tr ng-repeat="color in colors">
<td>{{ color.one }}</td>
<td>{{ color.two }}</td>
<td>{{ color.three }}</td>
</tr>
</tbody>
</table>
控制器:
var SomeController = function ($scope, SomeService, $window) {
var colors= [];
SomeService.someFunction().success(function (data, status, header, config) {
colors= data;
}).error(function (data, status, headers, config) {
// handle error
});
};
基本上,我需要根据后端中的任何内容动态创建我的表......但是,问题是一旦我调用页面,它会自动加载列,然后一秒钟左右,它会得到从服务中返回。无论如何我可以延迟加载时间或让表格“刷新”自身以显示新数据。
【问题讨论】:
-
将
subscriptions包含在$scope.subscriptions= data这样的范围内,然后ng-repeat将是tr ng-repeat="subscription in subscriptions"> <td>{{ subscription.one}}</td> <td>{{ subscription.two }}</td> <td>{{ subscription.three }}</td> </tr>
标签: javascript html angularjs asynchronous angularjs-directive