angular.formatter.trim

Work in Progress This page is currently being revised. It might be incomplete or contain inaccuracies.

Description

Use trim formatter if you wish to trim extra spaces in user text.

Usage

In HTML Template Binding

<input type="text" name="bindExpression" ng:format="trim">

In JavaScript

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-live :input:last').val('  text  ').trigger('change');
       done();
     });
     expect(binding('value')).toEqual('value="text"');
   });