Filters in AngularJS are used to format the value of an expression for display to the user. They can be applied in
view templates, controllers, or services, and they allow you to transform data in various ways. Filters are particularly useful for tasks such as formatting
dates, currency, filtering arrays, and
modifying strings.
AngularJS provides several built-in filters, including:
currency: Formats a number as a currency (e.g., $1,234.56).
date: Formats a date to a specified format.
filter: Selects a subset of items from an array.
json: Formats an object as a JSON string.
limitTo: Limits the array or string to a specified number of elements or characters.
lowercase: Converts a string to lowercase.
number: Formats a number as a text string.
orderBy: Orders an array by an expression.
uppercase: Converts a string to uppercase.
currency Filter:
<p>{{ amount | currency }}</p>
<!-- If amount is 1234.56, this will display $1,234.56 -->
date Filter:
<p>{{ today | date:'fullDate' }}</p>
<!-- If today is a Date object, this will display the full date format, e.g., Monday, April 1, 2024 -->
uppercase Filter:
<p>{{ message | uppercase }}</p>
<!-- If message is "hello", this will display HELLO -->
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Filters in AngularJS are used to format the value of an expression for display to the user. They can be applied in view templates, controllers, or services, and they allow you to transform data in various ways. Filters are particularly useful for tasks such as formatting dates, currency, filtering arrays, and modifying strings.
In the angularJs filter are two types
Built-in Filters
AngularJS provides several built-in filters, including:
$1,234.56).Custom filter
In AngularJS, custom filters are used to set the value of an expression to be displayed to the user.
Use them
Read more
Filters in AngularJS
Custom Filters in AngularJS
What is a Filter and how to use it in AngularJS, Explain with an Example.