javascript - Change AngularJS ngTrim Behavior -
i using angularjs version 1.5.6. have large application lots of text areas , text inputs. discovered bug today caused default angularjs behavior of trimming input text type inputs. change behavior trimming default not trimming default.
is there easy way rather go through hundreds of textareas , text inputs in application. (perhaps globally or writing own directive?)
here documentation page describing default behavior of ng-trim (ngtrim).
the below directive should work input type=text fields. set value of ngtrim false default every input field. , similar 1 can created textarea if required.
.directive('input', function($compile){ return { link(scope, element, attrs) { if (element.attr('type') === 'text') { attrs.$set('ngtrim', 'false'); } } }; });
Comments
Post a Comment