Skip to content
Pau Codina edited this page Nov 2, 2015 · 13 revisions

Introduction

Microsoft SharePoint 2013 provides a powerful REST api that provides 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 amazing projects on SharePoint.

We strongly recommend learning Angular. If you want to maximize the capabilities of this module, you need to know the main components of Angular and how to use them (controllers, directives, services, promises, etc.).

Usage

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 enter the following code.

<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="/<path to your lib folder>/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>

In-Depth Guide

Reference Docs

Clone this wiki locally