Use trim formatter if you wish to trim extra spaces in user text.
<input type="text" name="bindExpression" ng:format="trim">
var userInputString = angular.formatter.trim.format(modelValue); var modelValue = angular.formatter.trim.parse(userInputString);
{String}
– Trim excess leading and trailing space.
Enter text with leading/trailing spaces: <input type="text" name="value" ng:format="trim" value=" book "/> <input type="text" name="value" ng:format="trim"/> <pre>value={{value|json}}</pre>
it('should format trim', function(){ expect(binding('value')).toEqual('value="book"'); this.addFutureAction('change to XYZ', function($window, $document, done){ $document.elements('.doc-example-live :input:last').val(' text ').trigger('change'); done(); }); expect(binding('value')).toEqual('value="text"'); });