title: How get acces to response.data value in AngularJS?
body: <p>I want do set data in my component by http requests, but outside $http.get data is undefined.</p>
  
  <p>How get response data outside $http.get?</p>
  
  <pre><code>'use strict';
   angular.
   module('filesApp').
   component('filesList', {
    template:
        '&lt;ul&gt;' +
          '&lt;li ng-repeat="file in $ctrl.files"&gt;' +
            '&lt;span&gt;{{file.data1}}&lt;/span&gt;' +
            '&lt;p&gt;&lt;a href="{{file.data2}}"&gt;Create&lt;/a&gt;&lt;/p&gt;' +               
          '&lt;/li&gt;' +
        '&lt;/ul&gt;',      
    controller: function FilesListController($http, $scope) {
        //need response.data here
                $http.get('/api/1').then(function (response) {
                if (response.data.error) {
                    return null;
                } else {                      
                    $http.get('/api/2' + response.data).then(function (response) {
                        if (response.data.error) {
                            return null;
                        } else {                              
                            //response.data contains data that I need.                              
                            return response.data;
                        }
                    });
                }
            });          
    }
  });
  </code></pre>