AngularJs filters and angularjs Filters

Source: Internet
Author: User

date format

{{1304375948024 | date}} // Result: May 3, 2011
{{1304375948024 | date: "MM / dd / yyyy @ h: mma"}} // Result: 05/03/2011 @ 6:39 AM
{{1304375948024 | date: "yyyy-MM-dd hh: mm: ss"}} // Result: 2011-05-03 06:39:08
 
number format
{{1.234567 | number: 1}} // Result: 1.2
{{1234567 | number}} // Result: 1,234,567
 
currency format
{{250 | currency}} // Result: $ 250.00
{{250 | currency: "RMB ¥"}} // Result: RMB ¥ 250.00
 
filter search
{{[{"age": 20, "id": 10, "name": "iphone"},
{"age": 12, "id": 11, "name": "sunm xing"},
{"age": 44, "id": 12, "name": "test abc"}
] | filter: 's'}} // Find the line containing s
  
// The result of the previous example: [{"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'}}} // Find the line whose name is iphone
  
// Result from the above example: [{"age": 20, "id": 10, "name": "iphone"}]
 
orderBy object sorting
 
{{[{"age": 20, "id": 10, "name": "iphone"},
{"age": 12, "id": 11, "name": "sunm xing"},
{"age": 44, "id": 12, "name": "test abc"}
] | orderBy: 'id': true}} // descending order of root id
  
{{[{"age": 20, "id": 10, "name": "iphone"},
{"age": 12, "id": 11, "name": "sunm xing"},
{"age": 44, "id": 12, "name": "test abc"}
] | orderBy: 'id'}} // Order in ascending order by id
 
limitTo string, interception of objects
 
{{"i love tank" | limitTo: 6}} // Result: i love
{{"i love tank" | limitTo: -4}} // Result: tank
  
{{[{"age": 20, "id": 10, "name": "iphone"},
{"age": 12, "id": 11, "name": "sunm xing"},
{"age": 44, "id": 12, "name": "test abc"}
] | limitTo: 1}} // Result: [{"age": 20, "id": 10, "name": "iphone"}]


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.