forked from angular/code.angularjs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular.formatter.trim.html
37 lines (36 loc) · 1.29 KB
/
angular.formatter.trim.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<h1>angular.formatter.trim</h1>
<fieldset class="workInProgress">
<legend>Work In Progress</legend>
This page is currently being revised. It might be incomplete or contain inaccuracies.
</fieldset>
<h2>Description</h2>
<p>Use trim formatter if you wish to trim extra spaces in user text.</p>
<h2>Usage</h2>
<h3>In HTML Template Binding</h3>
<tt>
<input type="text" ng:format="trim">
</tt>
<h3>In JavaScript</h3>
<tt ng:non-bindable>
var userInputString = angular.formatter.trim.format(modelValue);<br/>
var modelValue = angular.formatter.trim.parse(userInputString);
</tt>
<h3>Returns</h3>
<tt>{String}</tt> Trim excess leading and trailing space.
<h2>Example</h2>
<doc:example>
<doc:source>
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>
</doc:source>
<doc:scenario>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"');
});</doc:scenario>
</doc:example>