Image Picker Error

Hi,
I am a newbie with Ionic2 and currently working on an app that has access to the photo gallery. While I can access the gallery using imagePicker.getPictures, when I select multiple photos and select OK, I get an undefined error… tried removing the plugin and re-added it back… no luck.
It happens on the emulator and device as well

public openGallery (): void {
let options = {
maximumImagesCount: 8,

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

,image

Try the following instead

public openGallery (): void {
	let options = {
		maximumImagesCount: 8
	}

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

You should use the arrow functions instead, so this stays the same (the class). And you should do this pretty much everywhere, I haven’t had a case yet where function() {} was useful at least.

Another example to give you the idea

.then(
	(more, than, one, argument) => {

	},
	err => {

	},
	() => { // Complete, fires along with either of the above

	}
)