0

i try to show a table from angular
i use sharepoint api with angular get request in webpart (content edit) i see table data only if i edit webpart
screenshots(Regular mode)

screenshots(edit mode) regular mode

edit mode

whats wrong ?

1 Answer 1

1

The code below for your reference.

<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>

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.