I am encountering difficulties with the Image Picker ngCordova plugin in my ionic app. Whenever I try to execute the getPictures()
function on android (both on my device and emulator), the app crashes. The function works on IOS in the emulator but not on an actual IOS device. I have attempted to uninstall and reinstall the plugin, and even created a basic example app to rule out any interference from my original project, but to no avail.
Each time I invoke the getPictures
function, I receive the following TypeError:
[console.error] TypeError: Cannot read property 'getPictures' of undefined
Here is my controller code, directly copied from the website:
.controller('ThisCtrl', ['$scope', '$cordovaImagePicker', function($scope, $cordovaImagePicker) {
$scope.getImages = function() {
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
});
}
}])
My list of installed plugins includes:
cordova-plugin-console 1.0.2 "Console"
cordova-plugin-device 1.1.1 "Device"
cordova-plugin-image-picker 1.0.8 "ImagePicker"
cordova-plugin-splashscreen 3.1.0 "Splashscreen"
cordova-plugin-statusbar 2.1.1 "StatusBar"
cordova-plugin-whitelist 1.2.1 "Whitelist"
ionic-plugin-keyboard 1.0.8 "Keyboard"
I have also verified that ngCordova is included in my index.html:
<script src="lib/ngCordova/dist/ng-cordova.js"></script>
<script src="cordova.js"></script>
What could be causing this issue?