-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image not refreshed after taking a photo from a camera #6340
Comments
yes this is my own post but unfortunately no solution has been provided ... |
is |
i tried zone.run() on the line this.url = imageURI; => nothing what is funny is when i click again on the button to take the photo, i see that the page is refreshed behind just before the camera is launched, and i see my photo ( without using zone.run() ) .... is there a workaround to ask Angular to refresh the view ? zone.run() does not seem to work |
@zamrokk, try to update just a simple text - for example put in template as |
zone.run doesn't fix the problem for me. Here is my code (in ionic 2 project):
html:
I tried Camera.DestinationType.FILE_URL too. I'm sure the image is updated because when I scroll the page (maybe cause refresh the DOM) will make the image appeared. |
Even when I try a text update inside the getPicture callback, it also not updated. It could because of a multi-threading issue? |
@zamrokk You find a solution already? I tried whatever I could but still in vain. |
No the issue still remains. I use actually my workaround waiting for a fix
|
What is your workaround? @zamrokk |
@zhouhao27 where do you get the constructor of your component should look like export class PicutrePage {
constructor(app: IonicApp, nav: NavController, params: NavParams, NgZone zone) {
this.nav = nav;
this.thumbnail = 'img/placeholder.png';
this.zone = zone;
} |
ok, then you wrap your call inside zone.run() like this?
I just use zone.run without passing by constructor. |
Yes. Your workaround works. But only for DATA_URL, the FILE_URL won't work. Maybe [src] doesn't recognise the local device path? Thanks @zamrokk |
ok i made it worked, here below my full code :
|
@zamrokk Sorry what's your html? What is the Attachment? And how it's related to your html img element? Mine is:
If I passed the url by using FILE_URL, it won't work. But it works if I use DATA_URL now. |
|
Basically it's the same like what I do. You only wrapped the url into an object. My returned url is:
Don't know why it's not shown. |
Maybe I'll try on android to see if there is any difference. Thanks |
your are welcome |
Hiii.... need a help. Camera.getPicture({ |
1 similar comment
Hiii.... need a help. Camera.getPicture({ |
I had a similar problem. I was taking a picture and saving it on my app cache replacing the old. Then the filename was the same and even trying swapping the content of the variable containing the file name was not working. I don't know why but I was feeling the problem was related with some sort of caching of the browser running the hybrid app. I finally make it working by adding a '?' and a random number string at the end of my file name (e.g. myImage.jpg?09475637929). By changing the random number the browser was forced to refresh the image thus the content. Note: the ngZone solution was not working for me, and my solution doesn't rely on any ngZone. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I am using this simple code with ionic 2 :
Then this is my Typescript page :
After taking the picture, nothing is displayed. I noticed that the "src" is not updated by Angular. I tested a part of the code in comments thats works using "var image= ... image.src=..." but is directly manipulating the DOM and I don't want this.
Also, any code outside the async call camera block makes Angular to update the view, but any code inside the async call updates the view.
Please can you see where the problem is ?
The text was updated successfully, but these errors were encountered: