0

I am working on a web app, and I want to show data in a list, by category. I am getting back AJAX data that has a title, and a category. The code to get that is like this:

angular.module('getImageData', ['ngResource'])
  .factory('images', function ($resource)
  {
      return $resource('/ImageData/GetImages', {}, {
          query: { method: 'GET', isArray: true }
      });
  });

and then like this:

$scope.imageData = images.query(function (response)
{
    // This has become superfluous
    return response;
});

The AJAX call us occurring and I can see my data in Chrome.

Then here is my HTML:

<ul>
    <li data-ng-repeat="image in imagedata">
        <a href="">{{image.Title}}</a>
    </li>
</ul>

I intend to do this:

<ul>
    <li data-ng-repeat="image in imagedata | filter : {TypeFilter : 'a' }">
        <a href="">{{image.Title}}</a>
    </li>
</ul>

but for now I'm keeping it simple.

The list is never rendered. This is the HTML I see in chrome:

<ul>
  <!-- ngRepeat: image in imagedata -->
</ul>

I am assuming this means it ran before the data came back. How do I make it wait ?

Thanks.

cgraus
  • 784
  • 2
  • 9
  • 26

2 Answers2

3

You have a spelling mistake in image in imagedata. It should be image in imageData

You also do not need to write callback function for query

 $scope.imageData = images.query();
Fizer Khan
  • 88,237
  • 28
  • 143
  • 153
0

try changing this:

$scope.imageData = images.query(function (response)
{
    // This has become superfluous
    return response;
});

to this:

$scope.imageData = images.query(function (response)
{
    $scope.imageData = response;
});
J.Wells
  • 1,749
  • 12
  • 13