Amit Kumar

Amit Kumar

  • NA
  • 13
  • 520

Filtering Sharepoint list data

Feb 23 2018 6:01 PM
I'm new to development. I'm struggling with filtering the data related to specific field values in sharepoint list.
 
I'm using angularJs and REST to get the all items from sp list. I need to filter data based on Region, Country and sites in that country.
 
Any help is much appreciated.
 
I'm storing all items in one variable as
 
$scope.items= data.data.d.results;
 
In the data below, Region, Country, Sites and contact are the SharePoint list field names, My data looks something like this:
 
[{"Region":"EU","Country":"Germany","Sites":"Germansite1", "contact":"person1"}, {"Region":"EU","Country":"Spain","Sites":"Spainsite", "contact":"person2"}, {"Region":"EU","Country":"Germany","Sites":"Germansite2", "contact":"person3"}, {"Region":"NA","Country":"USA","Sites":"USsite", "contact":"person4"}, {"Region":"SA","Country":"Mexico","Sites":"Mexsite", "contact":"person5"}, {"Region":"EU","Country":"Hungary","Sites":"Hunsite", "contact":"person6"}, {"Region":"AP","Country":"China","Sites":"Csite", "contact":"person7"}, {"Region":"AP","Country":"Singapore","Sites":"Singaporesite", "contact":"person8"}, {"Region":"AP","Country":"India","Sites":"indiasite", "contact":"person9"}, {"Region":"EU","Country":"Italy","Sites":"ItSite", "contact":"person10"}]
 
I tried doing this:
 
ng-repeat="item in items | filter: {Country:'Singapore'}">{{item.Country}}
  
But if I use filter in this way then, if a new country is added to the list, it won't be filtered.
 
Any help? 

Answers (1)