【发布时间】:2017-01-26 01:33:38
【问题描述】:
近 2 天以来,我一直在寻找解决方案。 我正在尝试使用 ngCordova 相机插件。
我在 AngularJS 中使用 ionic-yeoman 框架。
我所做的是:
bower install --save ngCordova.
将ngCordova 添加到我的app.module。
安装了cordova相机插件:
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: Camera is not defined
【问题讨论】:
-
当您在浏览器上时,cordova 的功能不可用,只能在已部署的应用程序或模拟器中使用。
标签: android angularjs cordova yeoman ionic-framework