2015-07-10 92 views

回答

0

傢伙做這個例子:https://github.com/driftyco/ionic-example-cordova-camera/blob/master/plugins/org.apache.cordova.camera/doc/index.md

作爲第二選擇,您可以用imagePicker插件嘗試。

例子:

module.controller('ThisCtrl', function($scope, $cordovaImagePicker) { 
 

 
    var options = { 
 
    maximumImagesCount: 10, 
 
    width: 800, 
 
    height: 800, 
 
    quality: 80 
 
    }; 
 

 
    $cordovaImagePicker.getPictures(options) 
 
    .then(function (results) { 
 
     for (var i = 0; i < results.length; i++) { 
 
     console.log('Image URI: ' + results[i]); 
 
     } 
 
    }, function(error) { 
 
     // error getting photos 
 
    }); 
 
});

5

您可以使用相機科爾多瓦插件

科爾多瓦插件添加org.apache.cordova.camera

插件參考: https://github.com/apache/cordova-plugin-camera

示例代碼

$scope.getPhoto = function() { 

    var options = { 
     quality: 50, 
     destinationType: Camera.DestinationType.FILE_URI, 
     sourceType: Camera.PictureSourceType.SAVEDPHOTOALBUM, 
     mediaType: Camera.MediaType.ALLMEDIA, 
     saveToPhotoAlbum: true 

    }; 

    $cordovaCamera.getPicture(options).then(function(imageData) { 
     console.log("img URI= " + imageData);   
     //Here you will be getting image data 
    }, function(err) { 
     alert("Failed because: " + err); 
     console.log('Failed because: ' + err); 
    }); 

}; 

你只是需要設置sourceType的選項Camera.PictureSourceType.SAVEDPHOTOALBUM

1

你可以得到科爾多瓦插件ImagePicker BU使用下面的鏈接,

http://ngcordova.com/docs/plugins/imagePicker/

示例:

$scope.OpenGallery = function() { 
    var options = { 
     maximumImagesCount: 1, 
     width: 350, 
     height: 500, 
     quality: 50 
    }; 
    $cordovaImagePicker.getPictures(options).then(function (results) { 
     console.log(results); 
    },function(error) { 
     console.log(error); 
    }); 
}