- Home
- All Blogs
-
Angular JS - Filter- Interview questions
Angular JS - Filter- Interview questions
Published On:
7/7/2023
Author:
Admin
Q. 1 What is the use of filter in AngularJS?
A filter is used to format the value of the expression to display the formatted output. Angular JS allows us to write our own filter. Filters can be added to expressions by using the pipe character |, followed by a filter.
Filters can be applied in view templates, controllers, services and directives. It is important to know that filters are case-sensitive. There are some built-in filters provided by Angular JS such as Currency, Date, Filter, JSON, Limit, Lowercase, Number, Order by, and Uppercase.
Q. 2 Which of the filters are used for transforming data ?
filters are used to format data. Following is a list of filters used for transforming data:
- Currency - It formats a number to a currency format.
- Date - It formats a date to a specified format.
- Filter - It select a subset of items from an array.
- Json - It formats an object to a Json string.
- Limit - It is used to limit an array/string, into a specified number of elements/characters.
- Lowercase - It formats a string to lower case.
- Number - It formats a number to a string.
- OrderBy - It orders an array by an expression.
- Uppercase - It formats a string to upper case.
Q. 3 How to add uppercase filter in Expression ?
Add uppercase filter to an expression using pipe character. Here we've added uppercase filter to print student name in all capital letters.
Name in Upper Case: {{student.fullName() | uppercase}}
Q. 4 How to add lowercase filter in Expression ?
Add lowercase filter to an expression using pipe character. Here we've added lowercase filter to print student name in all lowercase letters.
Name in Lower Case: {{student.fullName() | lowercase}}
Q. 5 How to add uppercase filter in Expression ?
Add currency filter to an expression returning number using pipe character. Here we've added currency filter to print fees using currency format.
fees: {{student.fees | currency}}
Q. 6 How to add Currency filter in Expression ?
Add currency filter to an expression returning number using pipe character. Here we've added currency filter to print fees using currency format.
fees: {{student.fees | currency}}
Q. 7 Explain custom filters with an example.
We can create our own filters in AngularJS. It can be performed by associating the filter to our module. These types of filters are known as custom filters.
Your Comment:
(0) Comments: