-
Notifications
You must be signed in to change notification settings - Fork 16
Home
Microsoft SharePoint 2013 provides a powerful REST api that allows to access to all SharePoint elements (webs, lists, document libraries, users, etc.)
ngSharePoint aims to facilitate this REST access through a set of angular services and directives. This library has been developed to support and facilitate the construction of different real projects on SharePoint.
We strongly recommend learning Angular. If you want to maximize the capabilities of this module, you must know the main components of Angular and how to use them (controllers, directives, services, promises, etc.).
To use ngSharePoint you'll need to include this module as a dependency of your angular app. In any page of your SharePoint, include a Content Editor WebPart and put the next code inside.
<div ng-app="demoApp" class="ng-scope">
<div ng-controller="main">
<ul>
<li ng-repeat="announcement in announcements">
<h2>{{announcement.Title}}</h2>
<div ng-bind-html="announcement.Body | unsafe"></div>
</li>
</ul>
</div>
</div>
<!-- Include angular and ngSharePoint files -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.6/angular.min.js"></script>
<script src="/app/libs/ng-sharepoint.js"></script>
<script>
// Create a demoApp and include 'ngSharePoint' as a dependency
var demoApp = angular.module('demoApp', ['ngSharePoint']);
// ... add a main controller and inject SharePoint service
demoApp.controller('main', ['$scope', 'SharePoint', function($scope, SharePoint) {
// Get the current web
SharePoint.getCurrentWeb().then(function(web) {
// Get the announcements list
web.getList('Announcements').then(function(list) {
// Get items ...
list.getListItems().then(function(items) {
$scope.announcements = items;
});
});
});
}]);
</script>