From 2b77a694b3846e64848673b5628b7ca2149a83ad Mon Sep 17 00:00:00 2001 From: Gregory Pike Date: Mon, 27 Aug 2012 23:06:32 -0400 Subject: [PATCH] Disable trim an option for form fields using ng-model --- src/ng/directive/input.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index cd2f0cfc25ab..a90aa58669d9 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -372,6 +372,14 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) { var listener = function() { var value = trim(element.val()); + // Trim is great but sometimes we need that extra white space. + // To prevent using the trim add the attribute ng-trim with the value of "0" or "off" + // e.g. + if (attr.ngTrim === 'off' || attr.ngTrim == 0) { + value = element.val(); + } + + if (ctrl.$viewValue !== value) { scope.$apply(function() { ctrl.$setViewValue(value);