uploadcare / angular-uploadcare

Provides a directive for the Uploadcare widget.
MIT License
37 stars 16 forks source link

Widget Data Binding #23

Closed anas3636 closed 7 years ago

anas3636 commented 7 years ago

Hello all,

I have an issue with the upload care component on angular2. I use it like this to have a two way data binding. <input [(ngModel)]="project.mainImage" id="mainImage" type="hidden" role="uploadcare-uploader" />

When my project is already defined and I refresh the page sometimes it works sometimes no. And I'am unable to understand why.

Can someone Please help me

Zmoki commented 7 years ago

Hi!

Try to set up global this settings:

var UPLOADCARE_LIVE = false
anas3636 commented 7 years ago

Hey

Still The same probleme. But I have more details on : the problème is related to the delay from my server. in fact if the server is slow when I receive the data and the injecte it to the uploadcare widget this one doesn't refresh with the new value so it stays empty

Thank you so much

anas3636 commented 7 years ago

Ok I found the solution I needed to use an On change function to update the uploadcare Widget !

ngOnChanges(changes: SimpleChanges) { // only run when property "data" changed var widgetMainImage = uploadcare.Widget('#mainImage'); if (changes['mainImage']) { widgetMainImage.value(this.mainImage); } }

Thank you