Property 'callproducts' does not exist on type 'XMLHttpRequest'
Property 'callproducts' does not exist on type 'XMLHttpRequest'
Description: I used XMLHttpRequest in my project. I want to call another function when i get status.Below is my home.ts
code.
home.ts
onFileSelected(event)
is called when file is selected from input type, everything works fine except when i try to call this function
this.callproducts(data,0,c_altcode)
onFileSelected(event)
this.callproducts(data,0,c_altcode)
Please guide me how can i call this function
home.ts
home.ts
onFileSelected(event)
var file = event.target.files[0];
var url = window.URL.createObjectURL(file);
var oReq = new XMLHttpRequest();
oReq.open("GET", url, true);
oReq.responseType = "arraybuffer";
oReq.onload = function(e)
var arraybuffer = oReq.response;
var data = new Uint8Array(arraybuffer);
var arr = new Array();
for (var i = 0; i != data.length; ++i) arr[i] = String.fromCharCode(data[i]);
var bstr = arr.join("");
var workbook = XLSX.read(bstr,
type: "binary"
);
var first_sheet_name = workbook.SheetNames[0];
var worksheet = workbook.Sheets[first_sheet_name];
var final_arr = XLSX.utils.sheet_to_json(worksheet,
raw: true
);
if(oReq.status === 200)
if(final_arr[0].hasOwnProperty("Altcode"))
var c_altcode =final_arr[0].hasOwnProperty("Altcode");
// error comming in this line.
this.callproducts(data,0,c_altcode);
oReq.send(null);
// This is my `callproducts()` which i want to call.
callproducts(data,index,srch)
// some code here
Error: Property 'callproducts' does not exist on type 'XMLHttpRequest'.
callproducts
I edit my question. Please read.
– Kirandeep Kaur
Sep 13 '18 at 7:22
Maybe a stupid question, but why do you use XMLHttpRequest instead of HttpClient? The second is easier to use and test in Angular apps.
– Mac_W
Sep 13 '18 at 7:25
what is the way to call this function from inside another function ?
– user2828442
Sep 13 '18 at 8:12
0
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Well, where does
callproducts
exist?– nitind
Sep 13 '18 at 7:16