我尝试显示一张来自角度的桌子
我在Webpart中将Sharepoint api与angular get请求一起使用(内容编辑)
我只有在编辑Webpart时才能看到表数据
屏幕截图(常规模式)
屏幕截图(编辑模式) regular mode
怎么了?
答案 0 :(得分:0)
以下代码供您参考。
<h1>WelCome To Angular JS Sharepoint 2013 REST API !!</h1>
<div id="mytest" ng-app="SharePointAngApp" class="row">
<div ng-controller="spCustomerController" class="span10">
<table class="table table-condensed table-hover">
<tr>
<th>ID</th>
<th>Title</th>
</tr>
<tr ng-repeat="customer in customers">
<td>{{customer.ID}}</td>
<td>{{customer.Title}}</td>
</tr>
</table>
</div>
</div>
<style>
#mytest table,#mytest td, #mytest th {
border: 1px solid green;
}
#mytest th {
background-color: green;
color: white;
}
</style>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
<script type="text/javascript">
var myAngApp = angular.module('SharePointAngApp', []);
myAngApp.controller('spCustomerController', function ($scope, $http) {
$http({
method: 'GET',
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getByTitle('ListA')/items?$select=ID,Title",
headers: { "Accept": "application/json;odata=verbose" }
}).success(function (data, status, headers, config) {
$scope.customers = data.d.results;
}).error(function (data, status, headers, config) {
});
});
</script>