Introduction to AngularJS filters to format and transform and sort


AngularJS is providing set of filters to Format and Transform and Sort the data.

If we want to filter the data inside javascript objects or properties we need to write hundreds of lines of code. In order to archive this we need to spend number of resources and time, But in case of AngularJS it’s completely reverse.

AngularJS is providing in-built filters to format and transform and sort the data.

AngularJS format and transform filters

AngularJS format filters help us to format and transform our data using the following filters.

  1. currency:

    • We can use this currency filter to format currency into specific format

    • for example a decimal property is having just number (300), and now if you want to display that number in currency format like $300.

  2. date:

    • We will use this filter to format date into specific format like “DD/MM/YYYY” or “MM/DD/YYYY” …

  3. filter:

    • We will use this filter to get specific or subset of data from a json object or array

  4. json:

    • This filter allows you to convert a javascript object to JSON string.

    • most of the times we will use this in debugging.

  5. limitTo:

    • we will use this filter to limit a javascript array or string into a specific number of elements.

  6. lowercase:

    • we will use this filter to transform our string to lower case

  7. uppercase:

    • we will use this filter to transform our string to upper case

  8. number:

    • we will use this filter to format a number to string and limit number of decimal

AngularJS sorting filters

we will use sortBy filter to sort the data.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s