| 1. |
What are AngularJS filters? |
|
Answer» AngularJS FILTERS are mainly used for formatting an expression while displaying it to the user. These can be used in controllers or services or views. AngularJS provides several inbuilt filters such as currency, FILTER, DATE, JSON, limitTo, etc whose purpose is to format the data without actually changing its VALUE before merging to the expression and this is done by using the pipe character (|). AngularJS also provides support for registering and implementing custom filters and use them using the pipe symbol. Syntax for using filters: {{expression | filterName:filterInputParameter }}For example, to format data to display the currency symbol before the salary value of say 18000: {{salary | currency:'Rs.'}}The salary will be displayed as “Rs.18,000”. Here ‘Rs.’ is the input to currency filter to define formatting. If nothing is specified, the default is considered as Dollars ($). You can look into the implementation of different TYPES of filters in the official documentation of AngularJS here. |
|