将列表项检索到表中 [英] Retrieve list items into a table

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

问题描述

我正在尝试使用CEWP将列表项放入页面的表中.我正在使用list.svc.

我正在使用角度html和list.svc

这是主要功能

        $ scope.getlist = function getListItem(){

  var weburl = _spPageContextInfo.webServerRelativeUrl;
    var url = weburl +"/_vti_bin/listdata.svc/Testreport1?$select=*";
    $ .ajax({
       网址:url,
       方法:"GET",
       标头:{"Accept":"application/json; odata = verbose" },
       成功:功能(数据,状态){
            $ scope.listitems =数据;
        },
       错误:函数(数据,状态){

        }
    });
}

  $ scope.init = function(){
    $ scope.getlist();
  }

我正在获取数据,但无法从中检索列表字段值.

问题是我无法使用rest api,因为这是2010年.

请提出建议


解决方案

我已经测试了您的代码,并发现了一些有关您的代码的问题.

首先,无法将Ajax的响应数据直接分配给您的"


scope.listitems = data.d.results;

第二,当您在AngularJS框架下检索数据时,建议使用"


Hi,

I am trying to get my list items into a table in a page using CEWP. I am using list.svc. 

I am using angular html and list.svc

This is the main function

       $scope.getlist = function getListItem() {

  var weburl = _spPageContextInfo.webServerRelativeUrl;
    var url = weburl+ "/_vti_bin/listdata.svc/Testreport1?$select=*";
    $.ajax({
        url: url,
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: function (data,status) {
            $scope.listitems= data;
        },
        error: function (data,status) {

        }
    });
}

  $scope.init = function() {
    $scope.getlist();
  } 

I am getting data but not able to retrieve the list field values out of it.

The problem is I am not able to use rest api as this is 2010. 

Please suggest


解决方案

Hi,

I have tested your code and found some problems about your code.

First, The response data of Ajax couldn’t be directly assigned to your "


scope.listitems", you should write like this:


scope.listitems= data.d.results;

Second, When you retrieve data under AngularJS framework, it recommends to use "


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

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