2016-06-08 164 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