We have a page that is using AngularJS. I am creating a link:

<div ng-if="breakout.AttachmentFiles">
    <div ng-repeat="file in breakout.AttachmentFiles" style="display: flex; align-items:baseline;">
        <b style="width: 95px; text-align: right">Attachments:</b>
        <a href="file.Url">{{file.Url}}</a>

File structure is:

  else if (itemKey === "AttachmentFiles") {
    var foobar = [];

    angular.forEach(itemValue.results, function(value, key) {
      foobar.push({"Url": $location.$$host+value.ServerRelativeUrl+"", "FileName": value.FileName});

    console.log("AttachmentFiles | foobar: ", foobar);

    currentBreakout[itemKey] = foobar;

enter image description here

For the text of the href displays the correct url, but the link it self goes off to a /Pages/file.Url:

enter image description here

What am I doing wrong?


I changed

<a href="file.Url">{{file.Url}}</a>


<a href={{file.Url}}>{{file.Url}}</a>

and that gives me a new link:

enter image description here

So for some reason https://company.sharepoint.com/sites/siteName/Pages/ is being inserted before the actual URL.


With the help from Ganash's post about using {{}} instead of "" and adding http:// to the url, the link is now working correctly.

  • After it creates a link, inspect the anchor element and check if it creates a link correctly or not. Mar 19, 2019 at 16:06

1 Answer 1


Try using:

<a href="{{file.Url}}">{{file.Url}</a>


<a ng-href="file.Url">{{file.Url}}</a>
  • The {{}} got me the actual URL in it now, but for some reason the https://companyName.sharepoint.com/sites/siteName/pages is being inserted before the URL I want.
    – Holden1515
    Mar 19, 2019 at 16:17
  • Then you must be creating wrong url after fetching the attachments and adding in foobar. Mar 19, 2019 at 16:34
  • I agree. I don't know where. This is AngularJS which I am not not familiar with at all.
    – Holden1515
    Mar 19, 2019 at 16:37
  • 1
    I needed to include http:// in the url, now it is working as intended.
    – Holden1515
    Mar 19, 2019 at 17:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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