Re: [AngularJS] Accessing Data in A Chained Call (Angular 7) -- A 'this' Problem?

2019-03-07 Thread Harry Whitehouse
Very nice Sander!! I knew Ruby could have multiple returns, so it's great to know that for Angular as well! Harry On Thursday, March 7, 2019 at 1:32:47 AM UTC-8, Sander Elias wrote: > > Hi Harry, > > something like: > async findPrintAndScales() { > try { > await qz.websocket.connect(); > const

Re: [AngularJS] Accessing Data in A Chained Call (Angular 7) -- A 'this' Problem?

2019-03-07 Thread Sander Elias
Hi Harry, something like: async findPrintAndScales() { try { await qz.websocket.connect(); const printers = await qz.printers.find(); const devices = await qz.hid.listDevices(false); await qz.websocket.disconnect(); return [printers, devices]; } catch (e) { console.log('uhOh', e); } } should do t

Re: [AngularJS] Accessing Data in A Chained Call (Angular 7) -- A 'this' Problem?

2019-03-06 Thread Harry Whitehouse
That worked like a charm Sander!! Here's my code now: qz.websocket.connect().then(function() { return qz.printers.find(); }).then(printers => { console.log(printers); this.chosePrinter(printers); return qz.hid.listDevices(false); }).

Re: [AngularJS] Accessing Data in A Chained Call (Angular 7) -- A 'this' Problem?

2019-03-06 Thread Sander Elias
Hi Harry, I took a closer look to your screenshot. (BTW, pasting snippets as code makes it easier to spot issues and help you) It is a 'this' problem indeed. In JS, each function had it's own 'this' That means the 'this' in the function, is not your class. Hence the error. Replace the function w

Re: [AngularJS] Accessing Data in A Chained Call (Angular 7) -- A 'this' Problem?

2019-03-05 Thread Harry Whitehouse
Hello Tito! That function is in the same component class. It looks like this: choseScale(devices){ console.log("ChoseScaleData = " + devices); } At runtime, I get this in the browser console: qztray.component.js:49 TypeError: Cannot read property 'choseScale' of undefined

[AngularJS] Accessing Data in A Chained Call (Angular 7) -- A 'this' Problem?

2019-03-05 Thread Tito
Where is choseScale? I dont see it -- You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group. To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscr...@googlegroups.com. To post to this grou

[AngularJS] Accessing Data in A Chained Call (Angular 7) -- A 'this' Problem?

2019-03-05 Thread Harry Whitehouse
Some decade, I'm going to figure out how Angular works! I'm using Qz-Tray a great tools that allows me to get a list of HID devices and printers. The code is below: I have lots of great data which displays in console. But I have this consistent problem of extracting the data to other parts o