0

How to get PublishingImage field of a list using angular JS?

1 Answer 1

0

I don't think you can get it directly, but you can get it through FieldValuesAsHtml, but only if you query one and one item.

Something like this:

$http.get("/_api/Lists/GetByTitle('Articles')/Items").then(function (res) {
  angular.forEach(res.data.d.results, function (article) {
    $http({
      url: article.FieldValuesAsHtml.__deferred.uri,
      params: {
        $select: "PublishingImage"
      }
    }).then(function (res) {
      article.PublishingImage = res.d.PublishingImage;
    });
  });
});

You could also use $q.all to wait for the image urls to load, although there is no need, you can use {{article.PublishingImage}} in your template directly.
Note that the field will be encoded, so you'll need to either decode it or extract the url.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.