title: How to get variables value outside $http.get?
body: <p>New to angularjs. I have a simple controller which reads a json file using <code>$http.get</code>. Inside <code>get</code> I am assigning some values to variable <code>$scope.testTotal</code>. But they revert to default value when exiting <code>$http.get</code>. It is confusing that when I log the entire object to console, I can see the values but when logging a specific value it shows zero.  Could it be a variable scope issue or execution sequence issue?</p>
  
  <pre><code>'use strict';
  var app = angular.module("myApp", [ 'ngRoute']);
  
  app.controller("SummaryController", ['$scope', '$http', function ($scope, $http) {
  
      $scope.testTotal = {
          executionStatus: { total: 0, passed: 0, failed: 0, duration: 0 }
      };
  
      $http.get('dummy.json').success(function (data) {
          $scope.data = data;
          angular.forEach($scope.data, function (i) {
              $scope.testTotal.executionStatus.passed += i.passed;
              $scope.testTotal.executionStatus.failed += i.failed;
          });
      });
  
      console.log($scope.testTotal); //I can see nested object with assigned values
      console.log($scope.testTotal.executionStatus.passed); //Vanished. Shows default value zero
  }]);
  </code></pre>
  
  <p>dummy.json has</p>
  
  <pre><code>[
      {"passed": 30, "failed": 12},
      {"passed": 10, "failed": 8}
  ]
  </code></pre>
  
  <h2>edit</h2>
  
  <p>I have created <a href="http://plnkr.co/edit/GlrrB0DkoAXCGpVsC2La" rel="nofollow">http://plnkr.co/edit/GlrrB0DkoAXCGpVsC2La</a>. The objective of my question is: read value(s) from a nested json file (synchronously or asynchronously), assign it to a variable/object and use it to make a chart. Unfortunately I am unable to access the values I read.</p>