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.

2

2 Answers 2

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();
Sign up to request clarification or add additional context in comments.

Comments

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;
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.