title: AngularJS access controller $scope from outside
body: <pre><code>var theApp = angular.module('theApp', []);
  var app = angular.module('theApp', ['ui.bootstrap']);
  app.controller('MenuSideController', ['$scope','SnazzyService','$modal','$log', function($scope, SnazzyService, $modal, $log) {
      $scope.user.zoomlvl = '2';
  }]);
  </code></pre>
  
  <p>I have the above controller and it sets a <code>$scope</code> which I can only ever access the values from inside. </p>
  
  <p>But I seen somewhere that using the below I would be able to access the <code>$scope</code> but when I <code>console.log($scope)</code> the <code>$scope.user.zoomlvl</code> it doesn't exist.</p>
  
  <p>I cannot figure out how to access the <code>MenuSideController</code> $scope and update that with the <code>valZoom</code> variable.</p>
  
  <pre><code>var appElement = document.querySelector('[ng-app=theApp]');
  var $scope = angular.element(appElement).scope();
  console.log($scope);
  $scope.$apply(function() {
      $scope.user.zoomlvl = valZoom;
  });
  </code></pre>