0

In the navigation bar on the Sharpoint 2013 page I'm working on there is a link called News. If I click on it I navigate to a new page where I can see all the news blogs. I'm having difficulty writing the right get request in angularjs to get this url. I need this url for an "See all" link I have on my home page that is underneath all the links that navigate to each news.

Sometimes the News url looks like this: .../sites/easySTART/frettir/_layouts/15/start.aspx#/default.aspx <--- navigated from the blog list

and sometimes like this: .../sites/easySTART/frettir/default.aspx <-- navigated from the home page

it depends on where I'm navigating from.

This is my angularjs code:

  //+ "/_api/lists/getbytitle('" + newsList + "')
  $http.get("/sites/easySTART/" + newsBlogName + "/DefaultView").
  success(function(data, status, headers, config) {
    $scope.allNews = data.value;
    console.log($scope.allNews);
  }).
  error(function(data, status, headers, config) {
    console.log(data);
  });

I've tried many different versions, this one is completely wrong I just get "404 NOT FOUND". Now I just have the url hardcoded in my html, but I don't want that because the variable newsBlogName can vary between users of this solution, depends on the name of the blog.

This is my html and I want to use ng-href there:

<div class="adv_show_all_link adv_show_all_link_news">
    <a id="adv_see_all" href="https://advaniasky.sharepoint.com/sites/easySTART/frettir/default.aspx">See all</a> <!-- Needs a fix, don't want the link to be hardcoded -->
</div>

I'm really new to Sharepoint so I will be thankful for any help I can get :) ...hope my question is not to vague.

0

Try removing the Default.aspx altogether using only the site path.

https://advaniasky.sharepoint.com/sites/easySTART/frettir/

The weird url woth _layouts that you see at the top is due to a feature called Minimal Download Strategy, that is used to only refresh certain parts of the page to improve performance. I personally don't like neither the URL it forms nor some issues it causes, so typically try to turn it off from Site Settings > Manage Site Features> Minimal Download Strategy (MDS).

  • I tried to fetch the url like this but just got undefined. Not sure if it is possible to get this url, if the API even offers it. So instead I just build up the url by using window.location.host from the homepage, extract what I don't need and add what I need. I'm completely new to this, just started working with a Sharepoint team at a software company. – Margret Kristjansdottir Feb 13 '15 at 12:17
  • Is the code being executed from the same site collection or a different one? I.e. sites/easySTART – Amadeo Gallardo Feb 13 '15 at 12:23
  • It's injected in the webpart – Margret Kristjansdottir Feb 16 '15 at 8:15

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.