Controller does not catch JavaScript variable

56 views Asked by At

I am working in ASP.NET Boilerplate (ABP) and AngularJS. I am using controllers (to upload files) with Kendo upload on frontend. To access controller I am using clicking kendo button clicking it like:

($("#files").data("kendoUpload")).options.async = vm.uploadOptions(onUpdate);
$('.k-upload-selected').click();

Function vm.uploadOptions(onUpdate) takes list of Ids and returns retObject like

var retObject = { saveUrl: '/ControllerName/ActionName?id=15&id=16', autoUpload: false, batch: true }

Now the actual question: When I assign saveUrl in retObject like above or like

retObject.saveUrl = '/ControllerName/ActionName?id=195&id=196&id=197'

(ids hardcoded), the controller is entered (I have a breakpoint there) and I have a C# List with two elements.

When I assign url like:

vm.url = '/ControllerName/ActionName?fileId=' + fileIds[0];
len = fileIds.length;
for (var i = 1; i < len; i++) {
    vm.url += '&fileId=' + fileIds[i];
}
retObject.saveUrl = vm.url;

the controller is not entered.

Finally (this is what I use in code now), when I assign like

vm.url = '?fileId=' + fileIds[0];
len = fileIds.length;
for (var i = 1; i < len; i++) {
    vm.url += '&id=' + fileIds[i];
}
retObject.saveUrl = '/ControllerName/ActionName' + vm.url;

it does work - controller is entered with a proper list of ids.

When I copied dynamically generated (not working) string and assigned it as hardcoded it started working. Why it happens, I mean: why exactly the same string initialized in different ways makes different results?

0

There are 0 answers