First, built-in filter
1, case conversion:
Uppercase, lowercase
{{' Lower cap string ' | uppercase}} {"Tank is good" | lowercase}}
2.JSON format (Convert object to JSON string), the default output is JSON string:
{{{name: ' Zhangsan ', Age:15}}} {{{name: ' Zhangsan ', Age:15}|json}}
3, Numberformat:
{{1.2345|number:1}} 1.2 {{1.2345|number:3}}/ /1.235 {1234567|number}} //1,234,567
4.currecy currency format:
{{500|currency}} $500.00 {{250|currency: ' Rmb¥ '}} //rmb¥250.00
5.Date Format:
var app = Angular.module (' myApp ', []); App.controller (' Myctrl ', function ($scope) { $scope. Dateone = new Date (); Console.info (New Date (). ToJSON ()); $scope. Datetwo = new Date (). ToJSON (); /date (1464941268937)/ $scope. Datethree = ' 1464941268937 '; });
{{1304375948024 |date}} May 3, {{Dateone |date: ' Hh:mm:ss '}} //09:19:20 {{datetwo |date: ' Yyyy-mm-dd hh:mm:ss '}} 2017-09-19 09:19:20 {{datethree |date: ' YYYY year mm month DD Day '}} //June 03, 2016
6.Filter Search:
Find the line containing 4 {{[{"Age": "id": Ten, "Name": "iphone"}, {"Age": "id": one, "name": "Sunm Xing"}, {"Age": 44, "id": "Name": "Test ABC"}] | filter: ' 4 '}} //Find the name of the line containing the iphone {{[{"Age": "id": Ten, "Name": "iphone"}, {"Age": "id": one, "name": "Sunm Xing"}, {"Age": $, "id": +, "name": "Test ABC"}] | filter:{' name ': ' iphone '}}
Look for the row containing 4 [{"Age": $, "id": +, "name": "Test ABC"}] //Find the name of the line containing the iphone [{"Age": "id": "" Name ":" iphone "}]
7.LimitTo string or object interception:
{' I want you ' | limitto:3}} I w {{' I want you ' | limitto:-3}} //You {{[1,3,5]|limitto:1}} //[1] {{[1,3,5]|limitto : -1}} //[5]
8.Sort by order of objects:
According to the ID descending row {{[{"Age": "id": Ten, "Name": "iphone"}, {"Age": "id": one, "name": "Sunm Xing"}, {"Age": 44, " ID ":", "name": "Test ABC"}] | order: ' ID ': true}} //According to the ID ascending order {{[{"Age": "id": Ten, "Name": "iphone"}, {"Age": "id": one, "name": "Sunm Xing"}, {"Age": $, "id": +, "name": "Test ABC"}] | By: ' ID '}}
Sorted by ID Descending [{"Age": $, "id": +, "name": "Test abc"},{"Age": "id": one, "name": "Sunm Xing"},{"Age": "id": 10, " Name ":" "iphone"}] //based on the ID ascending order [{"Age": +, "id": Ten, "Name": "iphone"},{"Age": "id": one, "name": "Sunm Xing"}, {"Age": $, "id": +, "name": "Test abc"}]
Second, custom filter
var app = Angular.module (' myApp ', []); App.controller (' Myctrl ', function ($scope) { $scope. msg = "Runoob"; }); App.filter (' Reverse ', function () {//can inject dependent return function (text) { return Text.split (""). Reverse (). Join ("") ; } });
Filters for AngularJS filter filter