Mayork9604
Mayork9604

Reputation: 23

Ionic Native ImagePicker giving me an error

Type '{ title: string; message: string; maximunImagesCount: number; outType: number; }' has no properties in common with type 'ImagePickerOptions'.

I have no idea why this is happening followed multiple tutorials to no avail. I would like to know what's causing me this problem and how to solve it.

Here's the code.

choosePicture()
  {
let option = {
  title: 'Seleccione una imagen',
  message: 'Seleccione 1 imagen',
  maximunImagesCount: 1,
  outType: 0
};
this.imagePicker.getPictures(option).then(results=> {
  for(var i = 0 ; i< results.lenght; i++)
  {
    this.path = results[i];
    alert("Gallery Path: " + results[i]);
  }
},
  err => {
    alert("Error " + err);

})
}

Upvotes: 1

Views: 471

Answers (1)

Paresh Gami
Paresh Gami

Reputation: 4782

You have to convert option to ImagePickerOptions

choosePicture() {
    let option : ImagePickerOptions = {
        maximumImagesCount: 1
    };

    this.imagePicker.getPictures(option).then(results=> {
        for(var i = 0 ; i< results.lenght; i++)
        {
            alert("Gallery Path: " + results[i]);
        }
    },
    err => {
        alert("Error " + err);
    });
}

Also, you have to change your import like below.

import { ImagePicker, ImagePickerOptions } from '@ionic-native/image-picker';

ImagePickerOptions only have 5 below properties

  • maximumImagesCount
  • height
  • width
  • outputType
  • quality

Upvotes: 1

Related Questions