我试图在不访问手机内存的情况下在相同页面上显示通过相机拍摄的图像。有点像watsapp,我们只是从那里点击并上传。所以,就像我们捕获某些东西并在同一页面上自动显示它,我们有捕获按钮。在相同页面上用相机拍摄的离子显示照片
.controller('CameraCtrl', function($scope, $cordovaCamera) {
document.addEventListener("deviceready", function() {
var options = {
quality: 50,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: true,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 100,
targetHeight: 100,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false,
correctOrientation:true
};
$cordovaCamera.getPicture(options).then(function(imageData) {
var image = document.getElementById('myImage');
image.src = "data:image/jpeg;base64," + imageData;
}, function(err) {
// error
});
}, false);
})
app.js
.state('tab.detail', {
url: '/new-order/id',
views: {
'tab-new': {
templateUrl: 'templates/detail.html',
controller: 'DetailCtrl'
}
}
})
.state ('camera',{
url:'/camera',
templateUrl: 'templates/detail.html',
controller:'CameraCtrl'
})
HTML
<ion-content>
<div>
<div class="col text-right">
<p>
<a href="#/camera" class="camera-icon" ><i class="icon ion-camera"></i></a>
</p>
</div>
<p>
<img ng-src="image.src" />
<p>
</div>
</ion-content>
嗨** kk19 **,根据文档http://ngcordova.com/docs/plugins/camera/,您的代码看起来不错。你能告诉我你显示图像的错误吗? 谢谢 – Hiro
没有错误。相机工作正常,图像被存储,但我需要显示它在我的页面上,我们有相机选项的相同页面上。没有访问我的手机库 – kk19
我已经添加app.js代码上面检查它。相机工作正常捕捉图像,但我需要显示它在我们有相机选项的同一页面上。 – kk19