1

i have qz-tray.js on ionic, it is worked BUT after the successful print the app crashed when i want to navigate to other page, here is the logs

ionic.bundle.min.js:142 TypeError: Cannot read property 'params' of undefined
at i (ionic.bundle.min.js:423)
at Object.x.transitionTo (ionic.bundle.min.js:423)
at Array.<anonymous> (ionic.bundle.min.js:423)
at Object.e [as invoke] (ionic.bundle.min.js:73)
at g (ionic.bundle.min.js:423)
at ionic.bundle.min.js:423
at b (ionic.bundle.min.js:423)
at m (ionic.bundle.min.js:423)
at n.$broadcast (ionic.bundle.min.js:171)
at l (ionic.bundle.min.js:138)

i just put qz-tray.js as depedency and then on the controller

qz.websocket.connect().then(function () {
    return qz.printers.find('MobilePrinter');
}).then(function (printer) {
    var config = qz.configs.create(printer);
    var data = [respon.data];
    return qz.print(config, data).then(function () {
        qz.websocket.disconnect();
    });
})

it did print the data but after that the app crashed, any help would be appreciated, thanks.

[SOLVED]

this function affect array iteration (for in), i comment the prototype solved the problem (qz-tray.js line 500)

        stringify: function(object) {
            //old versions of prototype affect stringify
            var pjson = Array.prototype.toJSON;
            delete Array.prototype.toJSON;

            var result = JSON.stringify(object);

            Array.prototype.toJSON = pjson;

            return result;
        },
bowpunya
  • 106
  • 8

1 Answers1

0

Instead of modifying the upstream library, it would be a better permanent solution to:

  1. Check hasOwnProperty on iteration.

    --- OR ---

  2. Work with upstream project to find out what specifically about the pasted code that is breaking { enumerable: false, ... } on the prototype object.
Community
  • 1
  • 1
tresf
  • 7,103
  • 6
  • 40
  • 101
  • @bowpunya here's another possible solution: https://github.com/qzind/tray/issues/67#issuecomment-250049338 – tresf Oct 04 '16 at 22:45
  • 1
    @bowpunya We've added a workaround upstream and should correct the problem for you: https://github.com/qzind/tray/commit/e0658fdf8aacc9423fc8e7c0505047098b58c84a – tresf Oct 27 '16 at 05:15