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

Provide an option not to trim the value of input

Open freewind opened this issue 14 years ago • 6 comments

See the demo: http://jsfiddle.net/Freewind/A8VzX/

If you input something has leading or ending spaces, they will be automatically trimmed.

This is fine for most cases, but sometimes, I need the original value.

e.g. I hope the uses can input some markdown code block(which has 4 leading spaces), but I have no idea how to do this.

The trimming code of angular is here: https://github.com/angular/angular.js/blob/master/src/ng/directive/input.js#L373

I think trimmed value is good for "number" or "url" inputs, but not always for a normal text input.

I hope angular can provide an option to control it trim or not.

freewind avatar Jun 10 '12 15:06 freewind

+1

troynt avatar Jul 31 '12 04:07 troynt

+2

davestewart avatar Sep 19 '12 18:09 davestewart

A feature to resolve this has already been committed: https://github.com/angular/angular.js/commit/d519953a4b219035587e3fcb2e9cc52e02b408ca

symblify avatar Sep 19 '12 21:09 symblify

Thanks. I checked the 1.1 release, but didn't find it in there. Do you know when it will make it in? (In the meantime I've hacked my own local copy: https://groups.google.com/forum/#!topic/angular/culutawXUx8)

davestewart avatar Sep 19 '12 21:09 davestewart

This fix is now available (1.1.1 release).

symblify avatar Nov 27 '12 01:11 symblify

Yes, landed as https://github.com/angular/angular.js/commit/d519953a4b219035587e3fcb2e9cc52e02b408ca

pkozlowski-opensource avatar Nov 27 '12 07:11 pkozlowski-opensource