AngularJS Filter

Topics 

  • What is a filter? 
  • Built-in filters 
  • Using filters in Controllers, Services, Directives 
  • Creating a custom filter

What is a Filter? 

  • A filter formats the value of an expression 
    • {{1234.56789|number}} results in 1,234.568 
  • A filter can have arguments
    • number filter has fraction argument 
    • {{1234.56789|number:1}} results in 1,234.6 
  • A filter is used mostly in view templates, but could be used in the JavaScript code of controllers, services, directives 
  • Angular provides a set of built-in filters
    • number, currency, json, etc. 
  • You can and want create your own custom filters as well

 

Download course content