javascript - 使用 ionic 框架的 $cordova ImagePicker 插件时出现错误

标签 javascript angularjs ionic-framework cordova-plugins

我正在尝试使用 $cordovaImagePicker 集成图像预览和上传功能。但是当我尝试使用

$cordovaImagePicker.getPictures(options)
     .then(function (results) {
         for (var i = 0; i < results.length; i++) {
             console.log('Image URI: ' + results[i]);
         }
     }, function (error) {
          // error getting photos
     });

在我的 Controller 中它给了我这个错误。

Error: n.imagePicker is undefined
.getPictures@http://localhost/myApp/www/js/ng-cordova.min.js:8:15339
@http://localhost/myApp/www/js/controllers.js:468:13
invoke@http://localhost/myApp/www/lib/ionic/js/ionic.bundle.js:12877:14 instantiate@http://localhost/myApp/www/lib/ionic/js/ionic.bundle.js:12885:27
$ControllerProvider/this.$get</<@http://localhost/myApp/www/lib/ionic/js/ionic.bundle.js:17154:18
self.appendViewElement@http://localhost/myApp/www/lib/ionic/js/ionic.bundle.js:48176:24
ionicViewSwitcher.create/switcher.render@http://localhost/myApp/www/lib/ionic/js/ionic.bundle.js:46392:29
ionicViewSwitcher.create/switcher.init@http://localhost/myApp/www/lib/ionic/js/ionic.bundle.js:46312:11
self.render@http://localhost/myApp/www/lib/ionic/js/ionic.bundle.js:48050:5
self.register@http://localhost/myApp/www/lib/ionic/js/ionic.bundle.js:48008:5
updateView@http://localhost/myApp/www/lib/ionic/js/ionic.bundle.js:53315:11
.compile/</<@http://localhost/myApp/www/lib/ionic/js/ionic.bundle.js:53292:11
$RootScopeProvider/this.$get</Scope.prototype.$broadcast@http://localhost/myApp/www/lib/ionic/js/ionic.bundle.js:23412:15
transitionTo/$state.transition<@http://localhost/myApp/www/lib/ionic/js/ionic.bundle.js:40882:11
processQueue@http://localhost/myApp/www/lib/ionic/js/ionic.bundle.js:21881:27
scheduleProcessQueue/<@http://localhost/myApp/www/lib/ionic/js/ionic.bundle.js:21897:27
$RootScopeProvider/this.$get</Scope.prototype.$eval@http://localhost/myApp/www/lib/ionic/js/ionic.bundle.js:23093:16
$RootScopeProvider/this.$get</Scope.prototype.$digest@http://localhost/myApp/www/lib/ionic/js/ionic.bundle.js:22909:15
$RootScopeProvider/this.$get</Scope.prototype.$apply@http://localhost/myApp/www/lib/ionic/js/ionic.bundle.js:23198:13
done@http://localhost/myApp/www/lib/ionic/js/ionic.bundle.js:18351:36
completeRequest@http://localhost/myApp/www/lib/ionic/js/ionic.bundle.js:18541:7
requestLoaded@http://localhost/myApp/www/lib/ionic/js/ionic.bundle.js:18482:1

最佳答案

这是一个已知问题。图像插件会发生这种情况。删除您的平台和图像选择器插件。再次添加。应该可以解决。

关于javascript - 使用 ionic 框架的 $cordova ImagePicker 插件时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30140002/

相关文章:

javascript - jQuery 无法选择子项

reactjs - 使用 Firebase Auth Context 在 React-Ionic 应用程序中保护路由

angular - ionic 无效包名称 __ngcc_entry_points__.json

javascript - 可以从 Google Chrome 浏览器设置面板中的地址栏(书签)运行 Javascript 吗?

javascript - 正确使用 Javascript DOM

javascript - 使用 javascript 模拟链接的外观

javascript - 使用angularjs将一个盒子移动到一个随机位置

javascript - Angular $http.post 不返回 XML

angularjs - 为什么在 cloud9 中加载 ionic 项目需要很长时间?

javascript - JavaScript 中的引用问题?