ngx-avatar icon indicating copy to clipboard operation
ngx-avatar copied to clipboard

Avatar is not updated if src is removed dynamically

Open andbjer opened this issue 6 years ago • 9 comments

In a project I am working on, I want to users to be able to choose their own image as avatar, and use the "initials avatar" if they don't have an image. I also want them to be able to remove an image.

When removing the image, src is updated to null. This does not update the avatar, and the image is still showing.

I have made a StackBlitz demo demonstrating my issue.

I use the following workaround right now, but I think this is something the component should be able to handle internally:

<ngx-avatar *ngIf="src; else initialsAvatar" [src]="src" [name]="name" [size]="size"></ngx-avatar>

<ng-template #initialsAvatar>
  <ngx-avatar [name]="name" [size]="size"></ngx-avatar>
</ng-template>

andbjer avatar Jun 24 '19 05:06 andbjer

+1 If I will change the user dynamically, avatar still show 'old' photo

BobaFett58 avatar Jul 23 '19 08:07 BobaFett58

I can confirm this is a bug. You forget to bind the name property in your StackBlitz example btw.

odahcam avatar Jul 23 '19 11:07 odahcam

+1

vptcnt avatar Jul 23 '19 22:07 vptcnt

Same here.

bind src={{object.src}} doesn't change the image when has a new model

kamilwasyl avatar Jul 30 '19 14:07 kamilwasyl

any solutions for this ??

BobaFett58 avatar Oct 24 '19 11:10 BobaFett58

Same issue here, this question was asked almost a year ago, not sure that's gonna be fixed someday.

Adesfire avatar Apr 27 '20 12:04 Adesfire

I'm not sure but maybe the current master branch already fixes this. We just don't have a publish date for it. We should test to see if it fixes the issue, otherwise make this a feature request.

odahcam avatar Apr 27 '20 15:04 odahcam

Sounds good. I set a wrong string to src when I want to hide it, but that's not clean though, just a work around

Adesfire avatar Apr 28 '20 11:04 Adesfire

I am facing the same issue now, but assign random string worked for me

amitshinde110113 avatar Mar 09 '21 10:03 amitshinde110113