我使用 ng-repeat
渲染一个 HTML 表格
。我的控制器代码如下:
app.controller("fooCtrl", function($scope, WebSocket) {
$scope.foo = [ ... ];
WebSocket.start(function(data) {
// this is a callback on websocket.onmessage
// here is a for loop iterating through $scope.foo objects and updating them
});
});
正如您所看到的,我正在定期更新$scope.foo
数组。然而,我的视图构造方式如下:
<tr ng-repeat="item in foo">
...
</tr>
问题是,当我更新foo
时,我的表格不会重新渲染以显示新数据。
我该怎么解决这个问题?