SharePoint Pals
 | Sign In
How to filter, select and expand SharePoint API using PNP JS Core and Angular Js in a SharePoint AddIn Custom Action
by Krishna KV 2 Jan 2017
Team Leader, Aspire Systems
Today  :   93     Total  :    2250

In this article, we can have a look at how to perform  filter and expand operation on a SharePoint  look up field using PNP JS Core and Angular Js in a SharePoint AddIn Custom Action. To simulate this scenario , I have created 2 custom lists named Technologies and projects with below fields


· Title


· Title

· Technology (Lookup)

· Duration

Creating a SharePoint Hosted APP using angular JS

Add the required angular and PNP Javascript file


 var app = angular.module('projectApp', []);
 (function () {
     app.service('appService', ['$http','$q',function ($http,$q) {
         function getUrlParamByName(name) {
             name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
             var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
             var results = regex.exec(;
             return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
   this.getListByFilterExpand = function (title, filter,expand,select) {
             var d = $q.defer();
             $pnp.sp.crossDomainWeb(appWebUrl, hostWebUrl).lists.getByTitle(title).items.filter(filter).expand(expand).select(select).get().then(function (response) {
             return d.promise;


 (function () {
     app.controller('customMenuCtrl', ['$scope', 'appService', function ($scope, appService) {
         var listTitle = 'Projects';
 var id = getUrlParamByName('SPListItemId') ?
             getUrlParamByName('SPListItemId') : 1;
 appService.getListByFilterExpand(listTitle, 'TechnologyId eq ' + id, 'Technology', 'Id,Title,Technology/Title,Duration').then(function (response) {
                 $scope.projects = response;


 <script src="../Scripts/angular-1.5.8.js"></script>
 <script src="../Scripts/fetch.js"></script>
 <script src="../Scripts/es6-promise.min.js"></script>
 <script src="../Scripts/pnp.js"></script>
 <script src="../App/app.service.js"></script>
 <script src="../App/customMenu.ctrl.js.js"></script>
 <asp:Content ContentPlaceHolderID="PlaceHolderMain" runat="server">
     <WebPartPages:AllowFraming ID="AllowFraming" runat="server" />
     <div data-ng-app="projectApp">
         <div ng-controller="customMenuCtrl">
             <table class="table table-bordered">
                         <td>Project Name</td>
                         <td>Duration (in months)</td>
                     <tr ng-repeat="project in projects">

Run the project


It will display the technology based on ID 1.

Adding custom action menu to the list Technologies to list the project based on the technologies.





 <?xml version="1.0" encoding="utf-8"?>
 <Elements xmlns="">
   <CustomAction Id="b71dcf73-c914-44c3-9f2a-41271530058f.ViewProjectCustomAction"
                 Title="View Project">
     Update the Url below to the page you want the custom action to use.
     Start the URL with the token ~remoteAppUrl if the page is in the
     associated web project, use ~appWebUrl if page is in the app project.
     <UrlAction Url="~appWebUrl/Pages/Project.aspx?{StandardTokens}&amp;SPListItemId={ItemId}&amp;SPListId={ListId}" />

This attributes will enable to display the custom action menu URL as a dialog. HostWebDialog="true" HostWebDialogHeight="300" HostWebDialogWidth="900"



blog comments powered by Disqus

SharePoint Pals

SharePoint Pals, a community portal for SharePoint developers, Administrators and End Users. Let's join hands and share the point together.
Read this on mobile


Angular Js Training In Chennai
Advanced Angular Js training with real world developer scenarios
Angular Js, Web Api and Ionic for .Net Developers
All in one client side application development for .Net developers
Angular Js For SharePoint Developers
Get ready for the future. Its no more just C#

Get Connected

SharePoint Resources

SharePoint 2013 and 2010 Web Parts
Free Web Parts with Source Code for SharePoint Community

SharePoint 2013 Books and Tutorials
Collection of free SharePoint 2013 books and tutorials (eBooks, pdfs)

Supported By

Contribute your article and be eligible for a one month Free Subscription for Plural Sight. The Author of the most popular New Article (published in the previous month) will be awarded with a Free One month Plural Sight Subscription. Article can be sent to in a word document.

Related Resources

Recent Tweets

Twitter January 15, 00:25
How To Enable Target Value And Actual Value In #D3 Gauge Chart

Twitter January 15, 00:24
How To Open #SharePoint List Hyperlink Column In Modal #Popup Window

Twitter January 15, 00:24
Quick Introduction To #Asp.NetCore And It’s Features

Twitter January 15, 00:22
How To Configure #PerformancePoint Services To Use Secure Store In #SharePoint 2013

Twitter January 15, 00:21
How To Block Or Disable #Office365 Services

Follow us @SharePointPals
Note: For Customization and Configuration, CheckOutRecent Tweets Documentation