1、大写
{{'abcde' | uppercase}}
2、小写
{{'ABC' | lowercase}}
3、货币格式
{{12345 | currency}}
{{ 250 | currency:"RMB ¥ " }}
4、向指令添加过滤器
按照country排序
{{ x.name + ', ' + x.country }}
5、过滤输入
Document
{{ (x.name | uppercase) + ', ' + x.country }}
6、自定义过滤器
Document
{{'abc' | reverse}}
7、保留小数
{{149016.1945000 | number:2}}
8、查找
{{ [{"age": 20,"id": 10,"name": "iphone"},
{"age": 12,"id": 11,"name": "sunm xing"},
{"age": 44,"id": 12,"name": "test abc"}
] | filter:{'name':'iphone'} }}
9、截取
{{"1234567890" | limitTo :6}} // 从前面开始截取6位
{{"1234567890" | limitTo:-4}} // 从后面开始截取4位
10、排序
// 根id降序排{{
[
{"age": 20,"id": 10,"name": "iphone"},
{"age": 12,"id": 11,"name": "sunm xing"},
{"age": 44,"id": 12,"name": "test abc"}
] | orderBy:'id':true }}
// 根据id升序排
{{
[{"age": 20,"id": 10,"name": "iphone"},
{"age": 12,"id": 11,"name": "sunm xing"},
{"age": 44,"id": 12,"name": "test abc"}
] | orderBy:'id' }}
11、多个参数
Document
newString: {{"jj" | myfilter:1:2:3:5}}
12、多个filter
{{ expression | filter1 | filter2 | ... }}
13、filter可以接受参数
{{ expression | filter:argument1:argument2:... }}
14、controller中使用filter
Document
{{aa}}