您好,登錄后才能下訂單哦!
本篇文章給大家分享的是有關AngularJs 中有哪些過濾器,小編覺得挺實用的,因此分享給大家學習,希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。
date格式化
{{ 1304375948024 | date }} //結果:May 3, 2011 {{ 1304375948024 | date:"MM/dd/yyyy @ h:mma" }} //結果:05/03/2011 @ 6:39AM {{ 1304375948024 | date:"yyyy-MM-dd hh:mm:ss" }} //結果:2011-05-03 06:39:08
number格式化
{{ 1.234567 | number:1 }} //結果:1.2 {{ 1234567 | number }} //結果:1,234,567
currency貨幣格式化
{{ 250 | currency }} //結果:$250.00 {{ 250 | currency:"RMB ¥ " }} //結果:RMB ¥ 250.00
filter查找
{{ [{"age": 20,"id": 10,"name": "iphone"}, {"age": 12,"id": 11,"name": "sunm xing"}, {"age": 44,"id": 12,"name": "test abc"} ] | filter:'s'}} //查找含有有s的行 //上例結果:[{"age":12,"id":11,"name":"sunm xing"},{"age":44,"id":12,"name":"test abc"}] {{ [{"age": 20,"id": 10,"name": "iphone"}, {"age": 12,"id": 11,"name": "sunm xing"}, {"age": 44,"id": 12,"name": "test abc"} ] | filter:{'name':'iphone'} }} //查找name為iphone的行 //上例結果:[{"age":20,"id":10,"name":"iphone"}]
orderBy對像排序
{{ [{"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' }} //根據id升序排
limitTo字符串,對像的截取
{{ "i love tank" | limitTo:6 }} //結果:i love {{ "i love tank" | limitTo:-4 }} //結果:tank {{ [{"age": 20,"id": 10,"name": "iphone"}, {"age": 12,"id": 11,"name": "sunm xing"}, {"age": 44,"id": 12,"name": "test abc"} ] | limitTo:1 }} //結果:[{"age":20,"id":10,"name":"iphone"}]
以上就是AngularJs 中有哪些過濾器,小編相信有部分知識點可能是我們日常工作會見到或用到的。希望你能通過這篇文章學到更多知識。更多詳情敬請關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。