angular.widget.@ng:format

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

Description

The ng:format attribute widget formats stored data to user-readable text and parses the text back to the stored form. You might find this useful for example if you collect user input in a text field but need to store the data in the model as a list. Check out formatters to learn more.

Usage

In HTML Template Binding

<INPUT ng:format="formatter">
   ...
</INPUT>

Parameters

Example

This example shows how the user input is converted from a string and internally represented as an array.

Enter a comma separated list of items: <input type="text" name="list" ng:format="list" value="table, chairs, plate"> <pre>list={{list}}</pre> it('should check ng:format', function(){ expect(binding('list')).toBe('list=["table","chairs","plate"]'); input('list').enter(',,, a ,,,'); expect(binding('list')).toBe('list=["a"]'); });