Updates

Angular JS - Filter- Interview questions

Published On: 7/7/2023
Author: Admin
Share Now

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:

  1. Currency - It formats a number to a currency format.
  2. Date - It formats a date to a specified format.
  3. Filter - It select a subset of items from an array.
  4. Json - It formats an object to a Json string.
  5. Limit - It is used to limit an array/string, into a specified number of elements/characters.
  6. Lowercase - It formats a string to lower case.
  7. Number - It formats a number to a string.
  8. OrderBy - It orders an array by an expression.
  9. 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.

Advertisement

Subjects (Free Online Tests)

Your Comment:
Name :
Comment :
(0) Comments:

 Full Length Mock Tests
 Answers with Explanation**
 Timer Based Exams
 Instant Result and assesment
 Detailed analasys of Result