Jan Netherdrake Jan Netherdrake - 7 months ago 23
AngularJS Question

AngularJS ngRepeat update model

I use

to render a
html table
. My controller looks like so:

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

As you can see, I am updating the
array periodically. However, my view is constructed like so:

<tr ng-repeat="item in foo">

The problem is, when I update
, it doesn't re-render my table with new data.

How would I go about this problem?


Did you wrap the update in

$scope.$apply(function() {
  // update goes here

? This should solve the problem.