//controller
$scope.init = function (person) {
serviceObj.getAllItems().then(function (results) {
$scope.people = results;
});
};
//service.js
var getAllItems = function() {
var query = listEndPoint + "/GetByTitle('Test List')/Items?$select=*";
return baseService.getAllListItems(query);
};
// baseSvc.js http module
var getAllListItems = function(query) {
var deferred = $q.defer();
var url = baseUrl + query;
var resultsCol=[];
GetRows();
function GetRows() {
$http({
url: url,
method: "GET",
headers: {
"accept": "application/json;odata=verbose",
"content-Type": "application/json;odata=verbose"
}
})
.then(function(result) {
resultsCol = resultsCol.concat(result.data.d.results);
// If there's next set of data, "data.d.__next" will contain URL.
// If not then you’re at the end of the records list and the execution of the code will stop.
if (result.data.d.__next) {
url = result.data.d.__next;
GetRows();
}
else {
deferred.resolve(resultsCol);
}
}),(function(result, status) {
deferred.reject(status);
});
}
return deferred.promise; };
// ajx model
function GetAllThresholdItems(email) {
var url = _spPageContextInfo.webAbsoluteUrl +
"/_api/web/lists/getbytitle('Corporate Pass Booking')/items?$select=*,Pass_x0020_Type/Title&$expand=Pass_x0020_Type/Id&$top=1000";
// Variable to store the list item values.
GetRows();
function GetRows() {
return $.ajax({
url: url,
method: "GET",
headers: {
"Accept": "application/json; odata=verbose"
},
success: function (data) {
results = results.concat(data.d.results);
// If there's next set of data, "data.d.__next" will contain URL.
// If not then you’re at the end of the records list and the execution of the code will stop.
if (data.d.__next) {
url = data.d.__next;
GetRows();
}
else {
$.LoadingOverlay("hide");
filterMyBookingPassData(results, email);
}
},
error: function (error) {
$.LoadingOverlay("hide");
}
});
}
}
function filterMyBookingPassData(allBookingData, eMail) {
// $scope.myBookingData = $filter('filter')(allBookingData, {Staff_x0020_Email: eMail});
// picked up by angular
$scope.$apply(function () {
$scope.filteredItems = $filter('filter')(allBookingData, function (item) {
return item.Staff_x0020_Email == eMail;
});
});
}
No comments:
Post a Comment