Use trim formatter if you wish to trim extra spaces in user text.
Usage
In HTML Template Binding
<input type="text" ng:format="trim">
var userInputString = angular.formatter.trim.format(modelValue);
var modelValue = angular.formatter.trim.parse(userInputString);
Returns
String
– Trim excess leading and trailing space.
Example
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 :input:last').val(' text ').trigger('change');
done();
});
expect(binding('value')).toEqual('value="text"');
});