gpt4 book ai didi

angularjs - 使用 ionic 框架的条码扫描器

转载 作者:行者123 更新时间:2023-12-03 00:03:31 25 4
gpt4 key购买 nike

$scope.scanBarcode = function(){

$cordovaBarcodeScanner.scan().then(function(imageData){

alert(imageData.text);

console.log("Barcode format ->" + imageData.format);

console.log("Cancelled ->" + imageData.cancelled);

},
function(error) {

console.log("An error happened ->" + error);
});

};

这些是控制台中的错误

Error: [$injector:unpr] Unknown provider: $cordovaBarcodeScannerProvider <- $cordovaBarcodeScanner <- AppCtrl http://errors.angularjs.org/1.3.13/$injector/unpr?p0=%24cordovaBarcodeScannerProvider%20%3C-%20%24cordovaBarcodeScanner%20%3C-%20AppCtrl at REGEX_STRING_REGEXP (ionic.bundle.js:8762) at ionic.bundle.js:12696 at Object.getService [as get] (ionic.bundle.js:12843) at ionic.bundle.js:12701 at getService (ionic.bundle.js:12843) at invoke (ionic.bundle.js:12875) at Object.instantiate (ionic.bundle.js:12892) at ionic.bundle.js:17161 at IonicModule.controller.self.appendViewElement (ionic.bundle.js:48253) at Object.IonicModule.factory.ionicViewSwitcher.create.switcher.render (ionic.bundle.js:46450)(anonymous function) @ ionic.bundle.js:20306$get @ ionic.bundle.js:17256$get.Scope.$broadcast @ ionic.bundle.js:23421$state.transitionTo.$state.transition.resolved.then.$state.transition @ ionic.bundle.js:40889processQueue @ ionic.bundle.js:21888(anonymous function) @ ionic.bundle.js:21904$get.Scope.$eval @ ionic.bundle.js:23100$get.Scope.$digest @ ionic.bundle.js:22916$get.Scope.$apply @ ionic.bundle.js:23205done @ ionic.bundle.js:18358completeRequest @ ionic.bundle.js:18548requestLoaded @ ionic.bundle.js:18489XMLHttpRequest.send (async)(anonymous function) @ ionic.bundle.js:18526sendReq @ ionic.bundle.js:18327$get.serverRequest @ ionic.bundle.js:18043processQueue @ ionic.bundle.js:21888(anonymous function) @ ionic.bundle.js:21904$get.Scope.$eval @ ionic.bundle.js:23100$get.Scope.$digest @ ionic.bundle.js:22916$get.Scope.$apply @ ionic.bundle.js:23205bootstrapApply @ ionic.bundle.js:10147invoke @ ionic.bundle.js:12884doBootstrap @ ionic.bundle.js:10145bootstrap @ ionic.bundle.js:10165angularInit @ ionic.bundle.js:10059(anonymous function) @ ionic.bundle.js:34824trigger @ ionic.bundle.js:11443eventHandler @ ionic.bundle.js:11713

最佳答案

似乎您想将 ngCordova 包装器用于 cordova 插件条形码扫描仪。ngCordova 没有捆绑在 ionic 中

您是否将 ngCordova.js 文件添加到您的 index.html 文件中?

 <script src="lib/ngCordova/dist/ng-cordova.js"></script>

并将其添加到模块的依赖项

angular.module('mymodule', ['ngCordova'])

您可以使用 Bower 安装它

 bower install ngCordova

或从网站下载http://ngcordova.com/

关于angularjs - 使用 ionic 框架的条码扫描器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30773320/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com