uttesh / ngletteravatar

directive for the letter avatar for the given string like gmail, first letter of the given data will be the avatar .
http://uttesh.github.io/ngletteravatar/
MIT License
136 stars 36 forks source link

avatar won't update when data changed. #14

Closed quocnguyen closed 8 years ago

quocnguyen commented 8 years ago

ex: ng-letter-avatar(data="{{vm.selected.username}}")

when vm.selected changed, avatar still show the old one.

uttesh commented 8 years ago

@quocnguyen could you please put you issue related sample code in codepen which will help to understand the issue.. thanks.

andre-morassut commented 8 years ago

Here is the code pen : http://codepen.io/andre-morassut/pen/QyqNdj

The first avatar is with a harcoded data attribute such as "U", the second one has its data attribute declared as Angular expression (eg. {{expression}}).

Two issues here :

uttesh commented 8 years ago

@andre-morassut Thanks for the codepen i will look into that issue.

uttesh commented 8 years ago

@andre-morassut after analyzing the codepen its looks like angularjs 1.1.5 version isolation scope issue with directive, after changing the version from 1.1.5 to 1.1.6 its working fine without any changes updated forked codepen http://codepen.io/anon/pen/obGdaw.

looks like no need to change the directive code if con't upgrade the angularjs version i will give patch ngletteravatar.js as fix.

andre-morassut commented 8 years ago

@uttesh Thanks for your quick reply :) Indeed, now the avatar is displayed on the first page load. But it seems that your fork still suffers from the main issue raised by @quocnguyen : when I type in the input field, the avatar won't change. Tested on Chrome 47, IE11, FF43. Do you reproduce this issue?

uttesh commented 8 years ago

@andre-morassut could you please provide me the codepen if you have any that will help me to analyze the issue. thanks.

andre-morassut commented 8 years ago

The issue can be reproduced with your updated forked codepen : http://codepen.io/anon/pen/obGdaw. If you type in the input field, the avatar won't change.

motasay commented 8 years ago

@andre-morassut If you're in a hurry here's a hack that makes it work: http://codepen.io/anon/pen/WrJKoP

Thank you @uttesh for the plugin, it's fantastic!

andre-morassut commented 8 years ago

Thanks @motasay :)

uttesh commented 8 years ago

@motasay thanks for the hack fix. i will fix the issue once i'm done with my other library implementation.

@andre-morassut next release i will address this issue.

andre-morassut commented 8 years ago

@uttesh OK, great!

sean-stanley commented 8 years ago

My PR fixes this issue with very few lines of code. A codepen demo is here or just check out the code changes they should be easy to read.

http://codepen.io/anon/pen/xVxqwK?editors=1011

uttesh commented 8 years ago

Thanks guys for the hacks and support, made the changes in the library and added fix for this issue i.e. added 'dynamic' attribute if that is set to true then data scope will be watched for the updates and on scope apply event trigger watch() will create the updated letter avatar.