angularjs - Monaca + barcode scanner callback issue -


i trying monaca develop hybrid app using cordova barcode scanner plugin.

for reason, scan callback started behave not properly.

immediatly after scanning, syncing message dialog ("checking sync target files..."), "downloading files" dialog , then, finally, result dialog asked for. after closing result dialog, app goes index page, not want.

here code (i use onsen ui):

js/app.js

var app = angular.module('hello', ['onsen']);  app.controller('testcontroller', ['$scope',function($scope) {     $scope.scan = function() {         window.plugins.barcodescanner.scan(function(result) {           alert( result.text);         }, function(error) {           alert('scan error');        });     } }]); 

index.html

<!doctype html> <html ng-app="hello"> <head>     <title>barcode</title>      <meta charset="utf-8">     <meta name="viewport" content="width=device-width, user-scalable=no">     <script src="components/loader.js"></script>     <link rel="stylesheet" href="components/loader.css">       <script src="js/app.js"></script> </head>  <body>     <div ng-controller="testcontroller">         <input type="button" ng-click="scan()" value ="scan !" />     </div> </body> </html> 

maybe related way plugin has called ?

see http://community.phonegap.com/nitobi/topics/_barcodescanner_plugin_upgrading_scanner_javascript_api_code_changes_required :

the barcodescanner plugin on phonegap build getting update today, , apps using need change code use cordova.require:

old:

window.plugins.barcodescanner.scan(function(){ ... }, function(){ ... }, optionsobj)  

new:

var scanner = cordova.require("cordova/plugin/barcodescanner"); scanner.scan(function (result) {...}, function (error) {...}); 

thanks help.

for reason, culprit monaca debugger parameter :

in monaca app > debugger settings > turn off "restart after resume"


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -