I'm making an ajax call to get some info from a server and then update a list on the screen. The information is coming back, but the scope isn't being updated! I've tried using $apply(), and I'm only getting an error
Code looks like this:
Inside correct controller, in HTML:
<div ng-controller=controller_1>
  <div ng-controller=controller_2>
    <button ng-click="myfunction()">click</button>
  </div>
</div>
In angular controller_1, we have $scope.vendorsarray defined
In the angular controller_2, $scope is injected, we have
$scope.function = function(){
  Factory.ajaxfactoryAction($scope.itemsarray).success(function(data, status, headers, config) {
    $scope.vendorsarray = data
    // POINT A
  }
// POINT B
}
Now, if I do a console.log($scope.vendorsarray) at points A and B, at B (which fires first, because it doesn't have to wait for the ajax), I get the old vendorsarray. At A, I then get the new, correct, vendorsarray. But then vendorsarray still isn't updated in the browser! What's going on?
Thanks for any help.
Edit
Here's how I tried to implement $apply():
$scope.function = function(){
  Factory.ajaxfactoryAction($scope.itemsarray).success(function(data, status, headers, config) {
    $scope.vendorsarray = data
    var temp = $scope.vendorsarray
    $scope.$apply(function() {
      $scope.vendorsarray = temp;
    });
  }
}
Here's the error (in the console):
https://docs.angularjs.org/error/$rootScope/inprog?p0=$digest
Error: error:inprog
Action Already In Progress
$digest already in progress
 
     
    