bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

Setting an empty string instead of null or empty object when editable is false

Open rpdmiranda opened this issue 11 years ago • 3 comments

When the user clears the input field, the parser returns an empty string instead of null. This may cause problems when the controller expects the ng-model to be an object.

I fixed this changing the line 3719, inside the parser function:

if (!inputValue) {
            // Reset in case user had typed something previously.
            // An empty string is not always the best value to return
            modelCtrl.$setValidity('editable', true);
            return null;

rpdmiranda avatar Jan 10 '15 23:01 rpdmiranda

Thx. It would be great if you could send a PR with appropriate tests. Rgds

antoinepairet avatar Jan 11 '15 08:01 antoinepairet

I have just made a plunker to show this issue at http://plnkr.co/edit/dDTdi7

rpdmiranda avatar Jan 11 '15 12:01 rpdmiranda

I’d rather have it the other way, returning an empty string always (if not touched, or cleared later)…

mirabilos avatar Aug 23 '16 15:08 mirabilos