科尔多瓦相机 - 离子 [英] Cordova Camera - Ionic

查看:200
本文介绍了科尔多瓦相机 - 离子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找为长达近2天的解决方案。
我试图用相机ngCordova插件。

I've been looking up for a solution for up to almost 2 days. I'm trying to use the ngCordova Camera plugin.

我使用的离子,自耕农框架,AngularJS。

I'm using the ionic-yeoman framework with AngularJS.

我所做的是:

bower install --save ngCordova.

新增 ngCordova 我的 app.module
安装了摄像头科尔多瓦插件:

Added ngCordova to my app.module. Installed the cordova camera plugin:

cordova plugin add org.apache.cordova.camera.

我的控制器:

.controller('profileCtrl', function($scope, myService, $cordovaCamera)
{
  $scope.takePicture = function() {
    var options = { 
        quality : 75, 
        destinationType : Camera.DestinationType.DATA_URL, 
        sourceType : Camera.PictureSourceType.CAMERA, 
        allowEdit : true,
        encodingType: Camera.EncodingType.JPEG,
        targetWidth: 100,
        targetHeight: 100,
        popoverOptions: CameraPopoverOptions,
        saveToPhotoAlbum: false
    };

    $cordovaCamera.getPicture(options).then(function(imageData) {
      // Success! Image data is here
    }, function(err) {
      // An error occured. Show a message to the user
    });
  }

  myService.getFoo().then(function(data) {
   //this will execute when the 
   //AJAX call completes.
   $scope.items = data;
  });
})

和我得到这个错误:的ReferenceError:相机没有定义

And I get this error:ReferenceError: Camera is not defined

推荐答案

如果您通过的浏览器上,无论你使用的服务您的应用程序科尔多瓦有关设备的使用,不能正常工作。但是,如果你即使是在模拟器或设备本身提供应用程式后遇到的问题。请尝试以下步骤。

If you are serving your app through browser, whatever you use of cordova regarding the usage of device, doesn't work. But, if you are having the problem even after serving your app in emulator or the device itself. Try the following steps.

首先,检查科尔多瓦插件列表:

进入项目目录类型:科尔多瓦插件列表


  1. 看到科尔多瓦-插件媒体捕获科尔多瓦-插件相机(如果这些未在列表中,你只是缺少你的插件)。
    运行命令
    科尔多瓦插件添加科尔多瓦 - 插件媒体捕获科尔多瓦插件添加科尔多瓦 - 插件相机

  1. see for cordova-plugin-media-capture, cordova-plugin-camera (if these are not in the list, you are simply missing your plugins). Run the command cordova plugin add cordova-plugin-media-capture and cordova plugin add cordova-plugin-camera

如果插件在那里,您仍然有没有被定义相机的问题

If the plugins are there and you are still having the issue of camera is not defined


  • 科尔多瓦插件RM科尔多瓦 - 插件相机

  • 科尔多瓦插件RM科尔多瓦 - 插件媒体捕获

  • 离子平台的android令吉

  • 离子平台的android添加

  • 科尔多瓦插件添加科尔多瓦 - 插件相机

  • 科尔多瓦插件添加科尔多瓦 - 插件媒体捕获

  • cordova plugin rm cordova-plugin-camera
  • cordova plugin rm cordova-plugin-media-capture
  • ionic platform rm android
  • ionic platform add android
  • cordova plugin add cordova-plugin-camera
  • cordova plugin add cordova-plugin-media-capture

必须符合以下present在您的index.html

Following must be present in your index.html

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

这篇关于科尔多瓦相机 - 离子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆