If I create a simple project:
ionic start MyApp
And add the ImagePicker plugin:
ionic plugin add https:
And just copy this example www folder into the project and execute:
ionic platform add android ionic build android ionic run android
Everything is working fine. I can select multiple images for their intended purpose without any errors.
So far so good. Now I tried to include this in my project, so I added the ImagePicker plugin. Now this is my list of plugins:
ionic plugin ls com.synconset.imagepicker 1.0.6 "ImagePicker" cordova-plugin-camera 1.1.0 "Camera" cordova-plugin-device 1.0.0 "Device" cordova-plugin-dialogs 1.1.0 "Notification" cordova-plugin-splashscreen 2.0.0 "Splashscreen" cordova-plugin-statusbar 1.0.0 "StatusBar" cordova-plugin-vibration 1.1.0 "Vibration" cordova-plugin-whitelist 1.0.0 "Whitelist"
I created a new module:
angular.module('App.ImageSelect', []) .config(function ($stateProvider, $urlRouterProvider) { $stateProvider.state('app.imageSelect', { url: "/products/prints/pola/imageSelect", views: { 'menuContent': { templateUrl: "modules/products/prints/pola/imageSelect/imageSelect.html", controller: 'ImageSelectController' } } }); }) .controller('ImageSelectController', function ($scope, $cordovaImagePicker) { $scope.images = []; $scope.selectImages = function () { $cordovaImagePicker.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); } ); }; });
As you can see, EXACTLY, SAME, is the controller that I copied from here that worked on a simple test project.
For any suspicious reason, this does NOT work. I always get the error:
TypeError: Cannot read property 'getPictures' of undefined
So what is this? I use EXACT the same code in both projects. In one, everything works, and in the other, nothing works. I tried all the examples described here, but its always the same.
angularjs cordova ionic-framework ngcordova
Mulgard
source share