title: AngularJS bindings delayed when code is inside SignalR callback
body: <p>I have some code that updates AngularJS $scope properties. If this code is run in a function, the web page is updated immediately. However, that same code, when running inside the SignalR callback function, won't immediately update the web page.</p>
  
  <p>Code that causes the bindings to update immediately:</p>
  
  <p>HTML with Angular bindings:</p>
  
  <pre><code>&lt;input id="name" type="text" ng-model="playerName" /&gt;&lt;button ng-click="RegisterPlayer();"&gt;Register&lt;/button&gt;
  </code></pre>
  
  <p>Function within Angular controller:</p>
  
  <pre><code>  $scope.RegisterPlayer = function () {
  
        $scope.numberOfPlayers += 1;
        var player = {
            name: $scope.playerName,
            randomNumber: 0,
            totalScore: 0
        }
        $scope.players.push(player);
    }
  </code></pre>
  
  <p>When this runs, the number of players is immediately upated on the web page.</p>
  
  <p>Here is how I refactored the code to send the info to a SignalR hub, and then use that same code within the SignalR callback:</p>
  
  <p>Here is the same function as above, but now it just sends the info to a SignalR hub:</p>
  
  <pre><code>  $scope.RegisterPlayer = function () {
  
        hub.server.send($scope.playerName, -1);
    }
  </code></pre>
  
  <p>And this is the code within the callback (it does get hit, so the wiring is correctly done):</p>
  
  <pre><code>  function receiveSignalRMessage(name, message) {
        var randomNumber = parseInt(message, 10);
  
        // -1 means the player was registered
        if (randomNumber == -1) {
            $scope.numberOfPlayers += 1;
            var player = {
                name: $scope.playerName,
                randomNumber: 0,
                totalScore: 0
            }
            $scope.players.push(player);
            return;
        }
    }
  </code></pre>
  
  <p>This actually works, except that the web page doesn't update the bindings until the next time a button is clicked on the page. It's the same code as before, but now it's just inside the callback. Why wouldn't my page update immediately?</p>