本文主要给大家介绍了Angular.Js过滤器filter与自定义过滤器filter的相关内容,分享出来供大家参考学习,下面来看看详细的介绍:
一、AngularJS的filter过滤器:
- uppercase|lowercase:大小写转换过滤
- json:json格式过滤
- date:日期格式过滤
- number:数字格式过滤
- currency:货币格式过滤
- filter:查找
- limitTo:字符串对象截取
- orderBy:对象排序
<Meta charset="UTF-8">
Angular基础
将字符串转换为大小写:
姓名为 {{ person.lastName | uppercase }}
姓名为 {{ person.lastName | lowercase }}
货币过滤:
数量:总价 = {{ (quantity * price) | currency }}
{{250 |currency:"RMB ¥"}}
按国家的字母顺序排序对象:
循环对象:
{{1288323623006 | date:'yyyy-MM-dd HH:mm:ss'}}
{{1.2345678 |number:1}}
{{ "i love tank" | limitTo:6 }}
{{ "i love tank" | limitTo:-6 }}
{{ [{"age": 20,"id": 10,"name": "iphone"},{"age": 12,"id": 11,"name": "sunm xing"},{"age": 44,"id": 12,"name": "test abc"} ] | orderBy:'id':true }}
{{ [{"age": 20,"name": "test abc"} ] | orderBy:'id' }}
{{1288323623006 | date:'yyyy-MM-dd HH:mm:ss'}}
{{1.2345678 |number:1}}
{{ "i love tank" | limitTo:6 }}
{{ "i love tank" | limitTo:-6 }}
{{ [{"age": 20,"id": 10,"name": "iphone"},{"age": 12,"id": 11,"name": "sunm xing"},{"age": 44,"id": 12,"name": "test abc"} ] | orderBy:'id':true }}
{{ [{"age": 20,"name": "test abc"} ] | orderBy:'id' }}
按输入的字母显示对象:
输入过滤:
name筛选:
{{ [{"age": 20,"name": "sunm"},"name": "test abc"}
] | filter:{'name':'sunm'} }}