0
我想要使用此代碼在controller.js顯示按鈕點擊一個對話框:條形碼掃描儀關閉一次,彈出犯規顯示
angular.module('app.controllers', ['ionic','ngCordova'])
.controller('page1Ctrl', ['$scope', '$stateParams', '$cordovaBarcodeScanner'
功能($範圍,$ stateParams,$ cordovaBarcodeScanner) {
document.addEventListener("deviceready", function() {
$scope.scanCode = function()
{
$cordovaBarcodeScanner.scan(
function (result) {
alert("We got a barcode\n" +
"Result: " + result.text + "\n" +
"Format: " + result.format + "\n" +
"Cancelled: " + result.cancelled);
},
function (error)
{
alert("Scanning failed: " + error);
}
);
}
});
}])
,但是當我在設備運行的應用程序,掃描儀的作品,但警告框,顯示細節不露面,和掃描儀一次檢測條形碼後關閉。可能是什麼問題呢?
我想你正在實施它錯誤的方式。嘗試http://ngcordova.com/docs/plugins/barcodeScanner/ –