title: angularjs $scope.$apply() gives this error: Error: [$rootScope:inprog]
body: <p>I'm trying to update some texts on a page that is part of $scope. But I keep getting this error:</p>
  
  <pre><code>Error: [$rootScope:inprog] [http://errors.angularjs.org/1.2.15/$rootScope/inprog?p0=%24apply][1]
  at Error (native)
  at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:6:450
  at m (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:101:443)
  at h.$apply (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:108:301)
  at h.$scope.changeLang (http://treenovum.es/xlsmedical/js/medical-app.js:80:16)
  at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:169:382
  at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:186:390
  at h.$eval (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:108:40)
  at h.$apply (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:108:318)
  at HTMLAnchorElement.&lt;anonymous&gt; (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:186:372) 
  </code></pre>
  
  <p>Obviously I'm doing something wrong. :)
  Any ideas of how I can fix this? I want the page to update to the new variables in the scope. </p>
  
  <p>This is the code I'm using for updating: </p>
  
  <pre><code>medicalApp.controller('MainCtrl', function($scope, $cookies, getTranslation) {
      getTranslation.get(function(data){
          $scope.translation = data;
      });
  
      $scope.changeLang = function (lang) {
          console.log(lang);
          $cookies.lang = lang;
          $scope.$apply(function(){
              getTranslation.get(function(data){
                  $scope.translation = data;
                  console.log(JSON.stringify($scope.translation));
              });
          });
      };
  });
  </code></pre>
  
  <p>the html:</p>
  
  <pre><code>&lt;body ng-controller="MainCtrl"&gt;
      ...
              &lt;div class="header-lang col-xs-4"&gt;
                  &lt;p&gt;
                      &lt;a href="#" ng-click="changeLang('de')"&gt;DE&lt;/a&gt; | 
                      &lt;a href="#" ng-click="changeLang('fr')"&gt;FR&lt;/a&gt;&lt;/p&gt;
              &lt;div&gt;{{ translation.text }}&lt;/div&gt;  &lt;---- Example variable I want updated.
      ...
  </code></pre>
  
  <p>I'm also using ngRoute with separate controllers for each page I load, if that has anything todo with it?</p>