forked from angular/code.angularjs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular.formatter.list.html
37 lines (36 loc) · 1.3 KB
/
angular.formatter.list.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.list</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 list formatter if you wish to convert the user entered string to an array.</p>
<h2>Usage</h2>
<h3>In HTML Template Binding</h3>
<tt>
<input type="text" ng:format="list">
</tt>
<h3>In JavaScript</h3>
<tt ng:non-bindable>
var userInputString = angular.formatter.list.format(modelValue);<br/>
var modelValue = angular.formatter.list.parse(userInputString);
</tt>
<h3>Returns</h3>
<tt>{Array}</tt> Array parsed from the entered string.
<h2>Example</h2>
<doc:example>
<doc:source>
Enter a list of items:
<input type="text" name="value" ng:format="list" value=" chair ,, table"/>
<input type="text" name="value" ng:format="list"/>
<pre>value={{value}}</pre>
</doc:source>
<doc:scenario>it('should format lists', function(){
expect(binding('value')).toEqual('value=["chair","table"]');
this.addFutureAction('change to XYZ', function($window, $document, done){
$document.elements('.doc-example :input:last').val(',,a,b,').trigger('change');
done();
});
expect(binding('value')).toEqual('value=["a","b"]');
});</doc:scenario>
</doc:example>