2016-06-08 168 views
0

我有qz-tray.js离子,它工作,但成功打印后,应用程序崩溃时,我想导航到其他页面,这里是日志qz-tray 2.0打印离子/ angularjs成功打印后崩溃

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) 

我只是把qz-tray.js为depedency,然后控制器

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(); 
    }); 
}) 

它确实打印数据上,但该应用程序崩溃后,任何帮助,将不胜感激,谢谢。

[解决]

此功能影响阵列迭代(在)中,i评论原型解决了这个问题(qz-tray.js线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; 
     }, 

回答

0

代替修改上游库,这将是一个更好的永久解决方案:

  1. 检查hasOwnProperty on iteration

    --- OR ---

  2. 与上游项目一起工作,找出粘贴代码breaking { enumerable: false, ... } on the prototype object的具体内容。
+0

您好,感谢您在这里的建议 – bowpunya

+0

@bowpunya是另一种可能的解决方案:https://github.com/qzind/tray/issues/67#issuecomment-250049338 – tresf

+1

@bowpunya我们上游增加了一个解决办法,并应为您解决问题:https://github.com/qzind/tray/commit/e0658fdf8aacc9423fc8e7c0505047098b58c84a – tresf