Reputation: 3986
I am trying to select multiple images from galary using cordova-imagePicker plugin. I am using cordova not ionic framework.
Here is the code.
<script type="text/javascript">
function selectPicture() {
window.imagePicker.getPictures(
function(results) {
for (var i = 0; i < results.length; i++) {
console.log('Image URI: ' + results[i]);
$scope.images.push(results[i]);
}
if(!$scope.$$phase) {
$scope.$apply();
}
}, function (error) {
console.log('Error: ' + error);
}
);
}
</script>
<center><a onclick="selectPicture();">Image Select</a></center>
I am testing it in android emulator. Plugin has been added and i can see that in plugin folder.
When i run the application in emulator it opened properly but after clicking on Image Select it terminate.
Any idea what am i doing wrong?
Please advise me the correct way.
Thanks
Upvotes: 1
Views: 2867
Reputation: 3611
This works. You didnt specify maximum Images count so one image was getting selected and imagePicker is closed.
Use maximumImagesCount in options as shown below:
window.imagePicker.getPictures(
function(results) {
for (var i = 0; i < results.length; i++) {
console.log('Image URI: ' + results[i]);
}
}, function (error) {
console.log('Error: ' + error);
}, {
maximumImagesCount: 10,
}
);
You can give an alert in the code and test.
Upvotes: 1