将 AngularJS 连接到 SharePoint 2010 列表 [英] Connect AngularJS to SharePoint 2010 List

查看:32
本文介绍了将 AngularJS 连接到 SharePoint 2010 列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的 AngularJS 应用程序连接到 Sharepoint 2010 列表.

I'm trying to connect my AngularJS App to a Sharepoint 2010 List.

我试过这个this 教程,但都不适合我.这 2 个教程使用的是 SharePoint 2013.

I've tried this and this tutorial but neither work for me. Those 2 tutorials are using SharePoint 2013.

那么第一个问题是:SharePoint 2010 是否有 RestAPI 供我连接?"- 如果SP 2010有这个功能,为什么我不能连接列表?

Well the first question is: "Does SharePoint 2010 have a RestAPI for me to connect with?" - If SP 2010 has this feature, why can't I connect with the list?

我的列表名为Steckbrief_Data",我尝试运行的代码是:

My list is called "Steckbrief_Data" and the code I'm trying to run is:

var app = angular.module('myApp', []); 
app.controller('myCtrl', function($scope, $http) {
        $http(
        {
            method: "GET",
            url: GetSiteUrl() + "_api/web/lists/getByTitle('Steckbrief_Data')/items"
            headers: {"Accept": "application/json;odata=verbose" }
        }).success(function (data, status, headers, config) {
            alert("success");
            $scope.Employees = data.d.results;
        }).error(function (data, status, headers, config) {
            alert("error");
        });
    }); 

function GetSiteUrl() {
    var urlParts = document.location.href.split("/");
    return urlParts[0] + "//" + urlParts[2] + "/" + urlParts[3] + "/" + urlParts[4];
}   

那么你能告诉我这里出了什么问题吗?

So could you tell me what is going wrong here?

谢谢和问候,迈克尔

推荐答案

SharePoint 2010 有一个 REST API,但它不像 2013 那样广泛.在您的情况下,'getByTitle' 不是 2010 API 的一部分.

SharePoint 2010 has a REST API, but it isn't as extensive as 2013's. In your case, 'getByTitle' is not part of the 2010 API.

在 2010 API 中,要获取列表数据,您的 URL 可能类似于:

In the 2010 API, to get list data, your URL might be something like:

http://yourserver/yoursite/_vti_bin/ListData.svc/Steckbrief_Data

其中 Steckbrief_Data 是您想要其数据的列表,http://yourserver/yoursite/ 是列表所在站点的路径.

Where Steckbrief_Data is the list whose data you want and http://yourserver/yoursite/ is the path to the site where the list resides.

如果这不起作用,请在浏览器中先尝试 http://yoursever/yoursite/_vti_bin/ListData.svc/.获取列表的内部名称并尝试用它代替 Steckbrief_Data

If this doesn't work off the bat, in a browser, try http://yoursever/yoursite/_vti_bin/ListData.svc/ first. Get the internal name of the list and try that in place of Steckbrief_Data

阅读更多详细信息此处

这篇关于将 AngularJS 连接到 SharePoint 2010 列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆