wilq
October 5, 2016, 11:11am
1
Typescript code:
ImagePicker.getPictures({ quality: 100, maximumImagesCount: 1}).then(results =>
{
this.image = results[0];
});
HTML:
<p>Image selected: {{ image }}</p> <img [src]="image" style="background: red; min-width: 10px; min-height: 10px;">
After i choose my photo page looks like this: ( there’s no photo )
Am I doing it the right way?
are you putting your images in the assets folder? (what version of Ionic are you using?)
wilq
October 5, 2016, 12:58pm
3
No I’m not putting images in the assets folder, photos needs to be loaded dynamically by ImagePicker from ionic-native.
How can I check version of ionic2?
Sorry - I misread your question and didn’t realise you were picking images.
BTW the version of Ionic that your project depends on will be in your package.json file.
wilq
October 5, 2016, 1:38pm
5
Thank you I solved problem by using File.readAsDataURL from ionic-native, I simply replaced previous typescript code (from first post) with:
ImagePicker.getPictures({ quality: 100, maximumImagesCount: 1}).then(results =>
{
File.readAsDataURL(results[0]).then(value => this.image = value, reason => this.failInfo = "Fail: " + reason);
});
fredDS
December 2, 2016, 12:59am
6
I currently facing the same issue. The way you’ve used readAsDataURL doesn’t match the definition in Ionic2 doc.
readAsDataURL(path, file)
Read file and return data as a base64 encoded data url. A data url is of the form: data:[][;base64].
So my question is, what is the path, the file? I try to pass one parameters, but it doesnt work.