I
I
Ilya2015-01-28 08:09:44
Apache Cordova
Ilya, 2015-01-28 08:09:44

How to take a photo using ngCorodva?

Method code like this:

$scope.sentPhoto = function(id_contact) {
      document.addEventListener("deviceready", function () {

        var options = {
          destinationType: Camera.DestinationType.DATA_URL,
          sourceType: Camera.PictureSourceType.CAMERA,
          encodingType: Camera.EncodingType.JPEG,
          popoverOptions: CameraPopoverOptions
        };

        $cordovaCamera.getPicture(options).then(function(imageData) {
          var image = document.getElementById('myImage');
          image.src = imageData;
          $http.post('http://site/api/v1/messages/index', {'id_user': $rootScope.userData.id_user, 'id_contact': id_contact, 'content': image.src, 'type': 'photo'})
          .success(function(data)
          {
            var alertPopup = $ionicPopup.show({
              title: '<h3>Photo sent!</h3>'
            });
            alertPopup.then(function(res) {
   						
            });
            $timeout(function() {
              alertPopup.close();
            }, 800);
          });
        }, function(err) {
          // error
        });

      }, false);
    };

The camera opens. Photographed. Everything. There is no further sign of the photo being sent to the server. It feels like whatever is in document.addEventListener is not firing. I've been trying to fight it all night. Tell me where to dig?
I use ngCordova and the code from the office. site.
$cordovaCamera in the controller is connected.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question