This article shows how to use the built-in filters in Angular.js. Built-in filters for filtering the data or changing the nature of data depending on needs.

The syntax will be like.

{{ expression | filter }}

Note. I am using Visual Studio 2012 (IDE) in this article, but you can use any kind of editor like Notepad, Notepad++, and so on.

Some built-in filters

Step 1. Create an ASP.NET Empty Web Application named "Angular_JS".

Web Application

Step 2. Add an HTML page into it named "Angular_Filter.html".

Add a page of html

Step 3: Download the Angular.js from the link Angularjs and save it to your website.

Download angular

Note. I am using Angular.min.js on this website.

Step 4. After adding the Angular.js to the website, write the script tag that will access the Angular file.

Angular file

Step 5. Now write the code using Directives and Data binding expressions into the page.

If I use some filters with "Data Binding Expression" then.

  1. uppercase: It will change all the letters to uppercase.
    {{ x | uppercase }}
    
    Output
    Uppercase
  2. lowercase: It will change all the letters into lowercase as in the following.
    {{ x | lowercase }}
    
    Output
    Lowercase
  3. Currency: It will change all the digits to currency and "$" is the default currency.
    {{ x | currency }}
    
    Output
    Currency
  4. Number: It will show all the digits with 3 decimal places by default as in the following.
    {{ x | number:8 }}
    
    Output. I am using 8 here.
    Number
  5. Date: It will change all the digits into the date according to some rules, like the default date will be "44 years 2 months 10 days" earlier, and 1000 will add 1 second into it.
    {{ x | date:'medium' }}
    
    Output: Change the 1 and 1000 into dates.
    Date
  6. limitTo: It will show the values depending on the limit of an array variable that has been set.
    {{ names | limitTo:2 }}
    
    Output: Here the limit is 2, so you can only see 2 values.
    LimitTo

Example

Step 6. Run the page and see the output.

Output