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.