First, introduce the next $filter service:
1, $filter is used for data format of the special services;
2, Angularjs built-in currency, date, filter, JSON, LimitTo, lowercase, uppercase, number, by the 8 filter;
3, filter can be nested use, with the pipe symbol "|" To separate (a bit like Linux);
4, filter can pass parameters;
5, user can customize filter.
Introduction to the built-in filter:
Currency: Used to format money, such as "$" or "¥" before a value.
Date: formats dates, which provide a rich date format.
JSON: Complete JSON formatting.
Number: such as turning into two decimal places.
ORDER BY: Sort.
Simple use of filter:
{{1304375948024 | date}}
{{1304375948024 | date: ' MM/DD/YYYY H:mma '}}
{{1304375948024 | date: ' YYYY-MM-DD hh:mm:ss '}}
{| currency}}
Output:
May 3, 2011
05/03/2011 6:39am
2011-05-03 06:39:08
$30.00
Custom filter:
eg
var mymodule = angular.module (' MyModule ', []);
Mymodule.filter (' Myfilter ', function () {return
function (item) {return
' Hi, ' +item
}} '
);
Using: {{' Jennylin ' | myfilter}}
The above content more detailed to introduce the angular of the $filter service, I hope to help you, if you have any questions welcome to my message, small series will promptly reply to everyone!