WABBIT0111
WABBIT0111

Reputation: 2313

Ionic $cordovaCamera.getPicture doesn't work.

I have an example ionic application that just take a picture from phone. I have a button in the tab-dash.html tab-dash.html I have a controller to do the picture taking logic controllers.js I have included ngCordova, all the required cordova plugins, but when i click take pictures on my phone, only the console log works, not the actual picture taking. What can be wrong here? You can visit the full repo https://github.com/7seven7lst/Ionic_test. below is a snippet of the code

angular.module('starter.controllers', [])

.controller('DashCtrl', function($scope) {
  $scope.inject = ['$cordovaCamera','$cordovaGeolocation','$cordovaFileTransfer'];
  $scope.log=function(){
    console.log('hello~~~');
  };


  $scope.takePicture = function() {
    console.log('taking pictures ....');
        var options = {
            quality : 75,
            destinationType : Camera.DestinationType.DATA_URL,
            sourceType : Camera.PictureSourceType.CAMERA,
            allowEdit : true,
            encodingType: Camera.EncodingType.JPEG,
            targetWidth: 300,
            targetHeight: 300,
            popoverOptions: CameraPopoverOptions,
            saveToPhotoAlbum: false
        };

        $cordovaCamera.getPicture(options).then(function(imageData) {
            $scope.imageURI = imageData;

            console.log('$scope.image is ', $scope.imageURI);
        }, function(error){
          console.log('the error is ', error);
        })

  };


})

Upvotes: 1

Views: 309

Answers (1)

Paresh Gami
Paresh Gami

Reputation: 4782

.controller('DashCtrl', function($scope)

Change above line to this, add $cordovaCamera

.controller('DashCtrl', function($scope,$cordovaCamera) 

Upvotes: 1

Related Questions