title: Assign value from then function to a variable promise
body: <p>I am trying to get hands in promises. SO i wrote a sample code like below</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html  ng-app="myApp"&gt;
    &lt;head&gt;
      &lt;meta charset="UTF-8"&gt; 
      &lt;script src="../angularjs.js"&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;div ng-controller="CartController"&gt;
      &lt;/div&gt;
  
    &lt;script&gt;
      var app = angular.module('myApp', []);
  
      app.controller('CartController',  function($scope, $q,$http){   
  
      $scope.newFun = function()
      {
        var defered = $q.defer();
        $http.get('data.json').success(function(data) {
          console.log(data);
          defered.resolve(data);
        })
        .error(function(data, status) {
          console.error('Repos error', status, data);
        });
        return defered.promise;
       }
  
       var newdata = $scope.newFun().then(
        function(data1) 
        {
          //console.log(data1);
          return data1;
        });
  
        console.log(newdata);
      });
    &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here i am trying to return the data got from the then function and assign it to a variable. But i am getting a $$ state object, which has a value key which holds the data. Is directly assigning the value is possible or inside the then function i need to use scope object and then access the data??</p>