如何在我之前选择的图像选择器中选择图像?

时间:2019-04-08 15:57:44

标签: angular image ionic4

我正在尝试显示以前在离子图像选择器中选择的图像。关闭图像选择器后,便无法标记以前选择的图像。

我已经浏览过文档,但是找不到任何选项

  this.imagePicker.getPictures({
      maximumImagesCount: 10
    })

1 个答案:

答案 0 :(得分:0)

您必须在导出类中声明: images :any[]=[]; 然后在您的函数中必须编写以下代码:

 getPhoto(){
    let options : ImagePickerOptions ={
      maximumImagesCount: 5, // number of pictures 
      quality:70,  // quality 70/100
      width: 512,  // optional
      height: 256, // optional
      outputType: 1 // type of output 1 if you want to use base64 or 0 for file_uri type

  };
    return this.imagePicker.getPictures(options).then( (res)=>{
      for (var i = 0; i < res.length; i++) {
        let nrm = `data:image/jpeg;base64,`+res[i];
        this.images.push(nrm); // this will push the links of pictures from your device to the array images 
    }
    })
  }

然后可以在html中用ngfor显示它