Home > Web Front-end > JS Tutorial > Detailed introduction to Angular js filters

Detailed introduction to Angular js filters

零下一度
Release: 2017-06-26 11:30:24
Original
1238 people have browsed it

1、uppercase,lowercase 大小写转换

{{ "lower cap string" | uppercase }}   // 结果:LOWER CAP STRING{{ "TANK is GOOD" | lowercase }}      // 结果:tank is good
Copy after login

2、date 格式化

{{1490161945000 | date:"yyyy-MM-dd HH:mm:ss"}} // 2017-03-22 13:52:25
Copy after login

3、number 格式化(保留小数)

{{149016.1945000 | number:2}}
Copy after login

4、currency货币格式化

{{ 250 | currency }}            // 结果:$250.00{{ 250 | currency:"RMB ¥ " }}  // 结果:RMB ¥ 250.00
Copy after login

5、filter查找

输入过滤器可以通过一个管道字符(|)和一个过滤器添加到指令中,该过滤器后跟一个冒号和一个模型名称。

filter 过滤器从数组中选择一个子集

 // 查找name为iphone的行{{ [{"age": 20,"id": 10,"name": "iphone"},{"age": 12,"id": 11,"name": "sunm xing"},{"age": 44,"id": 12,"name": "test abc"}] | filter:{'name':'iphone'} }}
Copy after login

6、limitTo 截取

{{"1234567890" | limitTo :6}} // 从前面开始截取6位{{"1234567890" | limitTo:-4}} // 从后面开始截取4位
Copy after login

7、orderBy 排序

 // 根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' }}
Copy after login

The above is the detailed content of Detailed introduction to Angular js filters. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template