Angularjs's built-in filter detailed

Source: Internet
Author: User
Tags json lowercase

In our development often need to display on the page to the user's information needs to be processed format, can be displayed to the user. In the ANGULARJS to provide us with the order called filter, so that we can easily do some of the functions of the column, Angularjs inside for us to provide a number of many built-in filter.

Today, let's take a look at Angularjs's built-in filters.

Let's take a look at these built-in filter usage methods:

A filter with no parameters

{{expression | filter}}

A filter, with parameters of the case

{{expression | filter:arguments}}

A filter, with multiple parameters of the case

{{expression | filter:arg1:arg2: ...}}

Multiple filters with no parameters

{{expression | filter1 | filter2 | ...}}

Below we use the following ANGULARJS built-in filters

Currency

Currency allows us to set our own currency symbol, which by default takes the currency symbol of the area where the client is placed.

You can use this: {{3600 | currency: ' $¥ '}}

Returns the result to $¥123.00

Online Code click Preview

Number

Number filter formats numbers as text, and its arguments are optional to control the number of bits intercepted after the decimal point

If a non-numeric character is passed in, an empty string is returned

You can use this: {{3600 | number:2}}

The result returned is: 3,600.00

Online Code click Preview

lowercase

Lowercase converts a string to lowercase

You can use this: {{' HEllo ' | lowercase}}}

Returns the result: Hello

Online Code click Preview

Uppercase

Uppercase converts a string to uppercase

You can use this: {{' HEllo ' | uppercase}}}

Returns the result: HELLO

Online Code click Preview

Json

The JSON filter converts a JSON or JavaScript object to a string.

This filter is quite useful for debugging

You can use this: {{{} ' name ': ' Dreamapple ', ' language ': ' Angularjs '} | json}}

The result returned is: {"name": "Dreamapple", "Language": "Angularjs"}

Online Code click Preview

Date

The date filter filters the dates into the format you want, which is a really good filter.

This filter uses a lot of me here to enumerate several commonly used

{{Today | date: ' YYYY-MM-DD '}}

The result is: 2015-15-13

{{Today | date: ' YYYY-MM-DD hh:mm::ss '}}

Results: 2015-18-13 20:18::38

[Online Code] (2015-18-13 20:18::38)

There are three built-in filters, but using a little more complexity, put it in the next article.

The above mentioned is the entire content of this article, I hope you can enjoy.

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.