0

I'm consume data by REST:

spApp.controller('blogCtrl', function ($scope, $http) {$http(
{
    method: "GET",  
    url: "https://company.sharepoint.com/lgblogg/_api/web/lists/getByTitle('Inlägg')/items?$select=Title,Author/ID,Author/Title&$expand=Author/ID,Author/Title')",                
    headers: { "Accept": "application/json;odata=verbose" }     
}
).success(function (data, status, headers, config) {
    $scope.Blogs = data.d.results;
    console.log('Gettings blog items');
}).error(function (data, status, headers, config) {}); });  

I can then display this by:

<div class="blueDIV">
                <div class="blog" ng-controller="blogCtrl">
                    <div ng-repeat="blog in Blogs">
                        <div class="Title"><a id="NewsLink" ng-href="https://company.sharepoint.com/lgblogg/default.aspx">{{blog.Title}}</a></div>
                        <br />
                        {{blog.Author.ID}}
                    </div>
                </div>
            </div>

This will display 18 (my user id) and i wonder if there some way that i can make a dynamic img ng-src to the authors imag/photo instead of just showing author name.

Im using REST and angularJS.

2 Answers 2

0

We can't expand the User field to return PictureURL. You need to invoke another Service Call. The easiest option is to query the User Information List

"/_api/Web/Lists/getByTitle('User Information List')/items?$filter=Id" eq + blog.Author.ID + "&$select=Picture"

This will return SP.FieldUrlValue and you can extract the Url property.

0
0

By changing REST to:

('Inlägg')/items?$select=Title,Author/ID,Author/FirstName,Author/LastName,Author/Title,Author/Department,Author/SipAddress&$expand=Author/ID')",       

And then using:

<img ng-src="https://outlook.office365.com/owa/service.svc/s/GetPersonaPhoto?email={{blog.Author.SipAddress}}"/>

The picture of the Author of the listitem will be displayed, amazing :D

2
  • sry for answering my own question, been on parentleave for two years. And my 10 years of SharePoint Consulting is a bit rusty :) Apr 15, 2015 at 12:52
  • No need to feel sorry. It helps people who are looking for similar solutions. Also You can mark your post as answer. Apr 15, 2015 at 12:53

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.