AngularJS built-in filter details

Source: Internet
Author: User

AngularJS built-in filter details

In our development, the information displayed on the page must be formatted to be displayed to the user. In angularjs, the filter command is provided for us, allowing us to easily implement some column functions. angularjs provides many built-in filters such as number.

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

Let's take a look at the usage of these built-in filters:

A filter without Parameters

{Expression | filter }}

A filter with Parameters

{Expression | filter: arguments }}

One filter with multiple parameters

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

Multiple filters without Parameters

{Expression | filter1 | filter2 | ...}}

Next we will use the following built-in AngularJS filters respectively.

Currency

Currency allows us to set our own currency symbols. By default, the currency symbols in the region where the client is located are used.

You can use: {3600 | currency: "$ "}}

The returned result is $¥123.00.

Online code Click Preview

Number

The number Filter formats A number into text. Its parameters are optional and used to control the number of truncated digits after the decimal point.

If a non-numeric character is input, an empty string is returned.

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

The returned result is 3,600.00.

Online code Click Preview

Lowercase

Lowercase converts a string to lowercase

You can use: {"HEllo" | lowercase }}

The returned result is: hello.

Online code Click Preview

Uppercase

Uppercase converts string to uppercase

You can use: {"HEllo" | uppercase }}

The returned result is: HELLO.

Online code Click Preview

Json

The json filter can convert a JSON or JavaScript object into a string.

This filter is quite useful for debugging.

You can use: {"name": "dreamapple", "language": "AngularJS"} | json }}

Returned result: {"name": "dreamapple", "language": "AngularJS "}

Online code Click Preview

Date

The date filter filters the date into the format you want. This is a good filter.

This filter has many common usage examples.

{Today | date: "yyyy-mm-dd "}}

Result: 2015-15-13

{Today | date: "yyyy-mm-dd HH: mm: ss "}}

Result: 2015-18-13 20: 18: 38

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

There are also three built-in filters, but the usage is a little more complicated. Let's discuss them in the next article.

The above is all the content of this article. I hope you will like it.

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.