ng2-image-upload icon indicating copy to clipboard operation
ng2-image-upload copied to clipboard

How to pass the url to uploadedfiles attribute from component to render in edit screen

Open agnaveen opened this issue 6 years ago • 4 comments

Hi,

I have uploaded the image in add screen to my server by specifying the server endpoint url in [url] attribute of image-upload. When I try to show the same image in my edit screen, If I put the complete url in [uploadedfiles] attribute then it is rendering properly. But If I pass the same url from component and try to render I am getting totally different behaviours like so many 404 urls generated in the console and also so many empty preview boxes appears in the UI.

The ways I tried is, Way 1: $storeLogoUrl -> Passing the name of the store from component. uploadedFiles="http://localhost:19999/store/logo/{{$storeLogoUrl}}"

Way 2: uploadedFiles="'http://localhost:19999/store/logo/'+$storeLogoUrl"

Way 3: [uploadedFiles]="'http://localhost:19999/store/logo/'+$storeLogoUrl"

Way 4: $storeLogoUrl - Full url I sent from controller itself. [uploadedFiles]="$storeLogoUrl"

Nothing worked out so far.

Can someone help me out here ?

agnaveen avatar May 17 '18 05:05 agnaveen

Finally by specifying like this [uploadedFiles]="[storeLogoUrl]" I am able to see the image in the preview in edit screen. But still one more image preview empty box is appearing.....

agnaveen avatar May 17 '18 05:05 agnaveen

Facing exactly the same issue. It gives one extra <div> (so temporarily used jQuery to hide the above div) $($('.img-ul-container').children(':first-child')).hide()

screenshot from 2018-05-25 14-52-41

monis01 avatar May 25 '18 09:05 monis01

@agnaveen @monis01 if you want to fix this issue add a ternary: [uploadedFiles]="image? [image]: ''"

bolota avatar Jun 02 '18 14:06 bolota

It works for me, thanks a lot @bolota

agnaveen avatar Jun 12 '18 07:06 agnaveen