title: AngularJS resource promise
body: <p>I've got a simple controller that use $resource : </p>
  
  <pre><code> var Regions = $resource('mocks/regions.json');
  
   $scope.regions = Regions.query();
  </code></pre>
  
  <p>I'm using this controller in a directive (in the link function)</p>
  
  <pre><code>var regions = scope.regions;
  </code></pre>
  
  <p>But regions is undefined. It's pretty logic the call is asynchronous. </p>
  
  <p>My question is how can i do to wait the result and regions be an array with all data ? </p>
  
  <pre><code>UPDATE : 
  </code></pre>
  
  <p>Here the definition of the directive</p>
  
  <pre><code>app.directive('ngMap', function() {
    return {
      restrict: 'EA',
      replace: 'true',
      scope: {
  
      },
      template: '&lt;div id="map"&gt;&lt;/div&gt;',
      controller: 'AccordMapCtrl',
      link: function(scope, element, attrs) {
        var regions = scope.regions;
        console.log(regions);
  
        for (var region in regions) {}
      };
    });
  </code></pre>