条码扫描仪立即关闭,弹出窗口不显示
barcode scanner closes at once, popup doesnt show
我正在尝试使用 controller.js 中的代码在单击按钮时显示警告框:
angular.module('app.controllers', ['ionic','ngCordova'])
.controller('page1Ctrl', ['$scope', '$stateParams', '$cordovaBarcodeScanner'
函数($scope、$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);
}
);
}
});
}])
但是当我 运行 设备中的应用程序时,扫描仪工作但显示详细信息的警告框不显示,并且扫描仪在检测到条形码后立即关闭。可能是什么问题?
尝试按照Documentation
中提到的方法
$cordovaBarcodeScanner
.scan()
.then(function(barcodeData) {
// Success! Barcode data is here
alert("We got a barcode\n" +
"Result: " + barcodeData.text + "\n" +
"Format: " + barcodeData.format + "\n" +
"Cancelled: " + barcodeData.cancelled);
}, function(error) {
// An error occurred
});
此致。
我正在尝试使用 controller.js 中的代码在单击按钮时显示警告框:
angular.module('app.controllers', ['ionic','ngCordova'])
.controller('page1Ctrl', ['$scope', '$stateParams', '$cordovaBarcodeScanner'
函数($scope、$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);
}
);
}
});
}])
但是当我 运行 设备中的应用程序时,扫描仪工作但显示详细信息的警告框不显示,并且扫描仪在检测到条形码后立即关闭。可能是什么问题?
尝试按照Documentation
中提到的方法$cordovaBarcodeScanner
.scan()
.then(function(barcodeData) {
// Success! Barcode data is here
alert("We got a barcode\n" +
"Result: " + barcodeData.text + "\n" +
"Format: " + barcodeData.format + "\n" +
"Cancelled: " + barcodeData.cancelled);
}, function(error) {
// An error occurred
});
此致。