How to capture image with device camera in ionic framework

1- İn controller.js write following codes,

.controller(‘CameraCtrl’, function($scope, $cordovaCamera,$http) { $scope.cameraImageArray = [];

$scope.getPhoto = function() {
var cameraOptions = {
quality: 100,

destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: false,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 500,
targetHeight: 500,
popoverOptions: CameraPopoverOptions(300, 300, 100, 100, Camera.PopoverArrowDirection.ARROW_ANY),
saveToPhotoAlbum: true
};

$cordovaCamera.getPicture(cameraOptions).then(function (imageURI) {
$scope.cameraImageArray.push({
src:imageURI
});

var save = {
imageURI:imageURI
}

alert(“Saved”);

}, function (err) {
//alert(“error ” + err);
});
} ;
});

2-İn your html file write following code

<div class=”row responsive-md”>
<div class=”col col-25″ ng-repeat=”image in cameraImageArray”>
<img ng-src=”{{image.src}}” width=”100%” />
</div>
</div>
<div>
<a class=”tab-item” ng-click=”getPhoto()”>
<i class=”icon ion-camera” ></i>
</a>
</div>

Figen Önün Kâşif on 29 Aralık 2015 yazdı
Yorum Ekle
  • 0 Yanıt(lar)
  • Yanıtınız

    Cevabınızı göndererek Gizlilik Politikası ve Hizmet Şartlarını kabul ediyorsunuz.