Imagine having an array within the client-side model:
vm.dataSheets = [
{ value: 0, text: localize.getLocalizedString('_ProductsAndServices_'), selected: selected},
{ value: 1, text: localize.getLocalizedString('_Holidays_'), selected: selected },
{ value: 2, text: localize.getLocalizedString('_Locations_'), selected: selected },
{ value: 3, text: localize.getLocalizedString('_OpHours_'), selected: selected },
{ value: 4, text: localize.getLocalizedString('_Users_'), selected: selected }
];
This array is connected to a checkbox list in the HTML. The goal is to send the values of the checked items to the web API. By using angularJS, you can filter the selected objects like this:
$filter('filter')(vm.dataSheets, { selected: true })
Instead of getting the entire object array, is there a quicker way to just retrieve the selected values as 1, 2, 3, etc...?
Currently, the data is sent to the Web API as shown below:
var fd = new FormData();
fd.append('file', file);
fd.append('clientId', $rootScope.appData.clientId);
fd.append('sheets', $filter('filter')(vm.dataSheets, { selected: true }));
$http.post("TIUSP/systemengine/ClientSupply", fd, {
withCredentials: true,
headers: {'Content-Type': undefined },
transformRequest: angular.identity
}).success(function () {
}
How can the selected values be retrieved in the web API? When using
HttpContext.Current.Request["sheets"];
a string such as [object, object][object, object] is returned.