Skip to content
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

Text doesn't update when it is changed dynamically (in js) #3

Closed
sdeering opened this issue Aug 26, 2014 · 3 comments
Closed

Text doesn't update when it is changed dynamically (in js) #3

sdeering opened this issue Aug 26, 2014 · 3 comments

Comments

@sdeering
Copy link

Text doesn't update when it is changed dynamically (in js).

For example, if you have a button which updates the text (runs the changeText function below) then the text doesn't update even though it's value has changed on the scope. Is the value used for text still binded to the scope variable?

$scope.longText = 'placeholder...';

$scope.changeText = function() {
  $scope.longText = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmodtempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,quis nostrud ';
};

It looks like 2 way binding is implied on the scope but it's not working.

scope: {
"=ngTextTruncate" 
...
@sdeering
Copy link
Author

I have tweaked the code to allow for updating when variable is changed. It's working now but does include a watch on the variable in the child scope (which is still two-way binded to the parent variable). Code is in my forked repo: https://github.com/sdeering/ng-text-truncate/blob/master/ng-text-truncate.js

@lorenooliveira
Copy link
Owner

Hi sdeering, thanks for pointing out the issue. I was quite busy in the last weeks so I've been postponing some updates to ng-text-truncate for some time.

I'm taking a look at your solution and I should release a fix by the end of today...

@lorenooliveira
Copy link
Owner

I've just pushed a fix. It's basically your idea, but with a cleaning of the element's contents before re-applying the truncate functions...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants