cleave.js icon indicating copy to clipboard operation
cleave.js copied to clipboard

Wrong model value updated in AngularJS when having multiple fields

Open markleusink opened this issue 10 years ago • 2 comments

If you have multiple fields on a form and they all use the same cleave options object, the wrong model values are updated. See this fiddle: https://jsfiddle.net/markleusink/ve758jjt/

I looked at the directive and think I know what's going on, am working on a solution.

markleusink avatar Sep 30 '16 11:09 markleusink

Just submitted a fix for this issue. The problem was caused by the two-way binding of the cleave attribute in the directive: the $scope.cleave object was overwritten in the precompile function for every instance, causing the object in the parent scope (options) to be updated. I fixed it by using a one-way object literal binding.

markleusink avatar Sep 30 '16 11:09 markleusink

Thanks a lot @markleusink merged!

nosir avatar Oct 05 '16 12:10 nosir